8670| 7
|
[项目] 小女孩的Micro:bit手表 |
我有java版 但只能看时间,调时间,没那么多功能 let ampm = false let hours = 0 let adjust = 0 let time = "" let minutes = 0 input.onButtonPressed(Button.AB, function () { ampm = !(ampm) }) input.onButtonPressed(Button.A, function () { if (hours < 23) { hours += 1 } else { hours = 0 } }) input.onGesture(Gesture.Shake, function () { adjust = hours if (ampm) { if (hours > 12) { adjust = hours - 12 } else { if (hours == 0) { adjust = 12 } } } time = "" + adjust time = "" + time + ":" time = "" + time + minutes / 10 time = "" + time + minutes % 10 if (ampm) { if (hours > 11) { time = "" + time + "PM" } else { time = "" + time + "AM" } } basic.showString(time) }) input.onButtonPressed(Button.B, function () { if (minutes < 59) { minutes += 1 } else { minutes = 0 } }) basic.forever(function () { basic.pause(60000) if (hours < 59) { minutes += 1 } else { minutes = 0 if (hours < 23) { hours += 1 } else { hours = 0 } } }) |
© 2013-2024 Comsenz Inc. Powered by Discuz! X3.4 Licensed