Microsoft MakeCode

M:B not reading ZIP Halo HD

I am trying to get my Micro:Bit to make use of the ZIP Halo HD’s RTC, but no luck so far.

The main program works just fine, making the Halo show the time with different colors and all, and with the possibility of adjusting time using the buttons on the M:B.

But when I try to get the M:B to use the RTC on the Halo, MakeCode cannot compile the program and it seems that it is because it cannot get info BACK from the Halo but only SEND info to the Halo.

I have created a line as: Set “value” to [read hours as number]", and then compare this “value” to a specific number. Here the simulator never receives a number, although I have set a specific time at startup. I have tried running the simulator in steps at turtle speed.

I have looked at the examples from Kitronik and done it the same way, but my compiler says “no luck fool.”

What am I not seen, and how do I get my M:B to actually retrieve data from the Halo?

Having done some simple tests, I have found that MakeCode will NOT compile the program, if I put in the line [Show NUMBER “Value” ] but MakeCode has no problem if instead I put in [Show STRING “Value” ] (and here I mean the variable “Value” from the post above, and not just some the written text “Value”).

Maybe the compiler think of the data from Zip Halo HD as a string and not a value, despite the [Read “hours” as NUMBER]. Why is this so (if it is), and how do I make it accept it as a value / number?

Can you share your project? That will make it easier for us to see the issue.

Hi.

I would not mind doing that, but how do I do so?

Bare in mind that the language of the project is in Danish, but hopefully people can still see what I have attempted.

The project could probably be reduced at certain places, but I am just interested in getting it to work.

Here is an attempt to post my project. Note that the issue (as I see it) seems to be under the function “show_clock_indicators”, where I have a [set “Housenumber_hours” to (Read “Hours” as Number)] and after that a condition [If “Housenumber_hours” is equal to “Housenumber_ON_time” then…] :

enum RadioMessage {

message1 = 49434,

On = 43154,

Mode_1 = 23411,

Mode_2 = 56276,

Mode_3 = 15758,

Mode_4 = 25688,

Mode_5 = 2665,

Mode_6 = 54001,

Mode_0 = 10458

}

function Hour_indicators () {

if (light_intensity <= 2) {

    light_intensity_hours = 2

} else {

    light_intensity_hours = light_intensity / 2

}

haloDisplay.setZipLedColor(0, kitronik_halo_hd.rgb(light_intensity_hours, 0, light_intensity_hours))

haloDisplay.setZipLedColor(5, kitronik_halo_hd.rgb(light_intensity_hours, 0, light_intensity_hours))

haloDisplay.setZipLedColor(10, kitronik_halo_hd.rgb(light_intensity_hours, 0, light_intensity_hours))

haloDisplay.setZipLedColor(15, kitronik_halo_hd.rgb(light_intensity_hours, 0, light_intensity_hours))

haloDisplay.setZipLedColor(20, kitronik_halo_hd.rgb(light_intensity_hours, 0, light_intensity_hours))

haloDisplay.setZipLedColor(25, kitronik_halo_hd.rgb(light_intensity_hours, 0, light_intensity_hours))

haloDisplay.setZipLedColor(30, kitronik_halo_hd.rgb(light_intensity_hours, 0, light_intensity_hours))

haloDisplay.setZipLedColor(35, kitronik_halo_hd.rgb(light_intensity_hours, 0, light_intensity_hours))

haloDisplay.setZipLedColor(40, kitronik_halo_hd.rgb(light_intensity_hours, 0, light_intensity_hours))

haloDisplay.setZipLedColor(45, kitronik_halo_hd.rgb(light_intensity_hours, 0, light_intensity_hours))

haloDisplay.setZipLedColor(50, kitronik_halo_hd.rgb(light_intensity_hours, 0, light_intensity_hours))

haloDisplay.setZipLedColor(55, kitronik_halo_hd.rgb(light_intensity_hours, 0, light_intensity_hours))

}

function set_clock_hours () {

while (setting_clock_time == 1) {

    haloDisplay.clear()

    haloDisplay.setZipLedColor(kitronik_halo_hd.readTimeForZip(TimeParameter.Hours), kitronik_halo_hd.rgb(light_intensity, 0, 0))

    haloDisplay.setZipLedColor(kitronik_halo_hd.readTimeForZip(TimeParameter.Minutes), kitronik_halo_hd.rgb(0, 0, 0))

    haloDisplay.setZipLedColor(kitronik_halo_hd.readTimeForZip(TimeParameter.Seconds), kitronik_halo_hd.rgb(0, 0, 0))

    haloDisplay.show()

    if (input.buttonIsPressed(Button.AB)) {

        setting_clock_time = 2

    } else if (input.buttonIsPressed(Button.A)) {

        kitronik_halo_hd.writeHours(kitronik_halo_hd.readTimeParameter(TimeParameter.Hours) + 1)

    } else if (input.buttonIsPressed(Button.B)) {

        kitronik_halo_hd.writeHours(kitronik_halo_hd.readTimeParameter(TimeParameter.Hours) - 1)

    }

    basic.pause(250)

    haloDisplay.setZipLedColor(kitronik_halo_hd.readTimeForZip(TimeParameter.Hours), kitronik_halo_hd.rgb(0, 0, 0))

    haloDisplay.show()

    if (input.buttonIsPressed(Button.AB)) {

        setting_clock_time = 2

    } else if (input.buttonIsPressed(Button.A)) {

        kitronik_halo_hd.writeHours(kitronik_halo_hd.readTimeParameter(TimeParameter.Hours) + 1)

    } else if (input.buttonIsPressed(Button.B)) {

        kitronik_halo_hd.writeHours(kitronik_halo_hd.readTimeParameter(TimeParameter.Hours) - 1)

    }

    basic.pause(250)

}

haloDisplay.showRainbow(1, 360)

haloDisplay.show()

while (input.buttonIsPressed(Button.AB)) {

    basic.pause(25)

    haloDisplay.rotate(1)

    haloDisplay.show()

}

for (let index = 0; index < 40; index++) {

    basic.pause(25)

    haloDisplay.rotate(1)

    haloDisplay.show()

}

haloDisplay.setZipLedColor(kitronik_halo_hd.readTimeForZip(TimeParameter.Hours), kitronik_halo_hd.rgb(light_intensity, 0, 0))

haloDisplay.show()

music.playTone(698, music.beat(BeatFraction.Eighth))

set_clock_minutes()

}

function set_clock_minutes () {

while (setting_clock_time == 2) {

    haloDisplay.clear()

    haloDisplay.setZipLedColor(kitronik_halo_hd.readTimeForZip(TimeParameter.Hours), kitronik_halo_hd.rgb(0, 0, 0))

    haloDisplay.setZipLedColor(kitronik_halo_hd.readTimeForZip(TimeParameter.Minutes), kitronik_halo_hd.rgb(0, light_intensity, 0))

    haloDisplay.setZipLedColor(kitronik_halo_hd.readTimeForZip(TimeParameter.Seconds), kitronik_halo_hd.rgb(0, 0, 0))

    haloDisplay.show()

    if (input.buttonIsPressed(Button.AB)) {

        setting_clock_time = 3

    } else if (input.buttonIsPressed(Button.A)) {

        kitronik_halo_hd.writeMinutes(kitronik_halo_hd.readTimeParameter(TimeParameter.Minutes) + 1)

    } else if (input.buttonIsPressed(Button.B)) {

        kitronik_halo_hd.writeMinutes(kitronik_halo_hd.readTimeParameter(TimeParameter.Minutes) - 1)

    }

    basic.pause(250)

    haloDisplay.setZipLedColor(kitronik_halo_hd.readTimeForZip(TimeParameter.Minutes), kitronik_halo_hd.rgb(0, 0, 0))

    haloDisplay.show()

    if (input.buttonIsPressed(Button.AB)) {

        setting_clock_time = 3

    } else if (input.buttonIsPressed(Button.A)) {

        kitronik_halo_hd.writeMinutes(kitronik_halo_hd.readTimeParameter(TimeParameter.Minutes) + 1)

    } else if (input.buttonIsPressed(Button.B)) {

        kitronik_halo_hd.writeMinutes(kitronik_halo_hd.readTimeParameter(TimeParameter.Minutes) - 1)

    }

    basic.pause(250)

}

haloDisplay.showRainbow(1, 360)

haloDisplay.show()

while (input.buttonIsPressed(Button.AB)) {

    basic.pause(25)

    haloDisplay.rotate(1)

    haloDisplay.show()

}

for (let index = 0; index < 40; index++) {

    basic.pause(25)

    haloDisplay.rotate(1)

    haloDisplay.show()

}

haloDisplay.setZipLedColor(kitronik_halo_hd.readTimeForZip(TimeParameter.Minutes), kitronik_halo_hd.rgb(0, light_intensity, 0))

haloDisplay.show()

music.startMelody(music.builtInMelody(Melodies.PowerUp), MelodyOptions.Once)

Tx_housenumber_MODE()

}

function Tx_housenumber_MODE () {

haloDisplay.clear()

basic.showIcon(IconNames.SmallHeart)

music.playTone(131, music.beat(BeatFraction.Half))

while (setting_clock_time == 3) {

    haloDisplay.clear()

    haloDisplay.setZipLedColor(Housenumber_MODE, kitronik_halo_hd.rgb(0, light_intensity, light_intensity))

    haloDisplay.show()

    if (input.buttonIsPressed(Button.AB)) {

        while (input.buttonIsPressed(Button.AB)) {

            

        }

        setting_clock_time = 0

    } else if (input.buttonIsPressed(Button.A)) {

        while (input.buttonIsPressed(Button.A)) {

            

        }

        if (Housenumber_MODE > 0) {

            Housenumber_MODE = Housenumber_MODE - 1

        } else {

            Housenumber_MODE = 6

        }

    } else if (input.buttonIsPressed(Button.B)) {

        while (input.buttonIsPressed(Button.B)) {

            

        }

        if (Housenumber_MODE < 6) {

            Housenumber_MODE = Housenumber_MODE + 1

        } else {

            Housenumber_MODE = 0

        }

    }

    basic.showNumber(Housenumber_MODE)

}

basic.clearScreen()

music.playTone(988, music.beat(BeatFraction.Half))

show_clock_indicators()

}

function indicating_setting_clock () {

music.startMelody(music.builtInMelody(Melodies.BaDing), MelodyOptions.Once)

haloDisplay.showRainbow(1, 360)

haloDisplay.show()

for (let index = 0; index < 120; index++) {

    basic.pause(25)

    haloDisplay.rotate(1)

    haloDisplay.show()

}

haloDisplay.clear()

set_clock_hours()

}

function Tx_housenumber_control () {

Housenumber_is_ON = 1

radio.sendMessage(RadioMessage.On)

if (Housenumber_MODE == 1) {

    radio.sendMessage(RadioMessage.Mode_1)

} else if (Housenumber_MODE == 2) {

    radio.sendMessage(RadioMessage.Mode_2)

} else if (Housenumber_MODE == 3) {

    radio.sendMessage(RadioMessage.Mode_3)

} else if (Housenumber_MODE == 4) {

    radio.sendMessage(RadioMessage.Mode_4)

} else if (Housenumber_MODE == 5) {

    radio.sendMessage(RadioMessage.Mode_5)

} else if (Housenumber_MODE == 6) {

    radio.sendMessage(RadioMessage.Mode_6)

} else {

    radio.sendMessage(RadioMessage.Mode_0)

}

}

function show_clock_indicators () {

while (setting_clock_time == 0) {

    haloDisplay.clear()

    Hour_indicators()

    haloDisplay.setZipLedColor(kitronik_halo_hd.readTimeForZip(TimeParameter.Hours), kitronik_halo_hd.rgb(light_intensity, 0, 0))

    haloDisplay.setZipLedColor(kitronik_halo_hd.readTimeForZip(TimeParameter.Minutes), kitronik_halo_hd.rgb(0, light_intensity, 0))

    haloDisplay.setZipLedColor(kitronik_halo_hd.readTimeForZip(TimeParameter.Seconds), kitronik_halo_hd.rgb(0, 0, light_intensity))

    haloDisplay.show()

    Housenumber_hours = kitronik_halo_hd.readTimeParameter(TimeParameter.Hours)

    if (Housenumber_hours == Housenumber_ON_time) {

        if (Housenumber_is_ON == 0) {

            Tx_housenumber_control()

        }

    } else {

        Housenumber_is_ON = 0

    }

    if (input.buttonIsPressed(Button.AB)) {

        setting_clock_time = 1

        indicating_setting_clock()

    }

    if (input.buttonIsPressed(Button.A) && !(input.buttonIsPressed(Button.B))) {

        if (light_intensity == 2) {

            light_intensity = 2

            while (input.buttonIsPressed(Button.A)) {

                

            }

        } else {

            light_intensity = light_intensity - 2

            while (input.buttonIsPressed(Button.A)) {

                

            }

        }

    }

    if (input.buttonIsPressed(Button.B) && !(input.buttonIsPressed(Button.A))) {

        if (light_intensity == 30) {

            light_intensity = 30

            while (input.buttonIsPressed(Button.B)) {

                

            }

        } else {

            light_intensity = light_intensity + 2

            while (input.buttonIsPressed(Button.B)) {

                

            }

        }

    }

}

}

let Housenumber_hours = 0

let light_intensity_hours = 0

let Housenumber_is_ON = 0

let Housenumber_MODE = 0

let Housenumber_ON_time = 0

let setting_clock_time = 0

let light_intensity = 0

let haloDisplay: kitronik_halo_hd.ZIPHaloHd = null

radio.setGroup(200)

kitronik_halo_hd.setBuzzerPin()

kitronik_halo_hd.setTime(22, 59, 0)

haloDisplay = kitronik_halo_hd.createZIPHaloDisplay(60)

light_intensity = 10

setting_clock_time = 0

Housenumber_ON_time = 23

Housenumber_MODE = 0

Housenumber_is_ON = 0

haloDisplay.showRainbow(1, 360)

haloDisplay.show()

for (let index = 0; index < 160; index++) {

basic.pause(25)

haloDisplay.rotate(1)

haloDisplay.show()

}

show_clock_indicators()

Oh, and I am using the Block editing version, so please inform me how to correct my project in that way.

I just copy-pasted it in java so you all could reed it, and hopefully help me.