Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Sep 27, 2023
2 parents baedb19 + 553e151 commit 496c3e9
Show file tree
Hide file tree
Showing 6 changed files with 304 additions and 86 deletions.
10 changes: 10 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
- code generation for car tiles
- keep MicroCode radio numbers to small range (0-99)
- range for car control (1000-)
- extensions [jacdac, car]
- extension interface
- also need some interface for tile description
- add metadata for a program (what extensions are needed)
- factor out jacdac modules and car into extensions
- assets.ts
- tiles.ts
285 changes: 219 additions & 66 deletions assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,38 @@ namespace microcode {
reg["railroad_crossing"] = icondb.sampleRailCrossingLight
}

function carImages(reg: name2Image) {
reg[TID_ACTUATOR_CAR] = icondb.car
reg[TID_MODIFIER_CAR_FORWARD] = icondb.car_forward
reg[TID_MODIFIER_CAR_REVERSE] = icondb.car_reverse
reg[TID_MODIFIER_CAR_TURN_LEFT] = icondb.car_left_turn
reg[TID_MODIFIER_CAR_TURN_RIGHT] = icondb.car_right_turn
reg[TID_MODIFIER_CAR_STOP] = icondb.car_stop
reg[TID_SENSOR_CAR_WALL] = icondb.car_wall
}

// TODO: factor out all the jacdac stuff into separate file/class
// TODO: so we can generate different builds
function jacdacImages(reg: name2Image) {
reg[TID_FILTER_KITA_KEY_1] = icondb.kita_key_1
reg[TID_FILTER_KITA_KEY_2] = icondb.kita_key_2
reg[TID_SENSOR_MAGNET] = icondb.magnet
reg[TID_SENSOR_SLIDER] = icondb.kita_slider
reg[TID_SENSOR_ROTARY] = icondb.kita_rotary
reg[TID_FILTER_ROTARY_LEFT] = icondb.kita_rotary_left
reg[TID_FILTER_ROTARY_RIGHT] = icondb.kita_rotary_right
reg[TID_ACTUATOR_RGB_LED] = icondb.rgbLed
reg[TID_MODIFIER_RGB_LED_COLOR_1] = icondb.tile_color_red
reg[TID_MODIFIER_RGB_LED_COLOR_2] = icondb.tile_color_green
reg[TID_MODIFIER_RGB_LED_COLOR_3] = icondb.tile_color_blue
reg[TID_MODIFIER_RGB_LED_COLOR_4] = icondb.tile_color_magenta
reg[TID_MODIFIER_RGB_LED_COLOR_5] = icondb.tile_color_yellow
reg[TID_MODIFIER_RGB_LED_COLOR_6] = icondb.tile_color_black
reg[TID_MODIFIER_RGB_LED_COLOR_RAINBOW] = icondb.tile_rainbow
reg[TID_MODIFIER_RGB_LED_COLOR_SPARKLE] = icondb.tile_sparkle
reg[TID_MODIFIER_SERVO_SET_ANGLE] = icondb.servo_set_angle
}

export class icons {
static reg: name2Image

Expand All @@ -39,6 +71,8 @@ namespace microcode {

this.reg = {}
extraSamples(this.reg)
if (car_tiles) carImages(this.reg)
jacdacImages(this.reg)
// editor icons
this.reg["delete"] = icondb.btn_delete
this.reg["plus"] = icondb.btn_plus
Expand Down Expand Up @@ -66,96 +100,91 @@ namespace microcode {
// sample icons
this.reg["smiley_buttons"] = icondb.sampleSmileyButtons

// sensors
// pages

this.reg[TID_SENSOR_START_PAGE] = icondb.tile_start_page
this.reg[TID_ACTUATOR_SWITCH_PAGE] = icondb.tile_switch_page
this.reg[TID_MODIFIER_PAGE_1] = icondb.tile_page_1
this.reg[TID_MODIFIER_PAGE_2] = icondb.tile_page_2
this.reg[TID_MODIFIER_PAGE_3] = icondb.tile_page_3
this.reg[TID_MODIFIER_PAGE_4] = icondb.tile_page_4
this.reg[TID_MODIFIER_PAGE_5] = icondb.tile_page_5

// looping
this.reg[TID_MODIFIER_LOOP] = icondb.loop

// variables

this.reg[TID_SENSOR_CUP_X_WRITTEN] = icondb.cupXwritten
this.reg[TID_SENSOR_CUP_Y_WRITTEN] = icondb.cupYwritten
this.reg[TID_SENSOR_CUP_Z_WRITTEN] = icondb.cupZwritten
this.reg[TID_FILTER_CUP_X_READ] = icondb.cupXread
this.reg[TID_FILTER_CUP_Y_READ] = icondb.cupYread
this.reg[TID_FILTER_CUP_Z_READ] = icondb.cupZread
this.reg[TID_ACTUATOR_CUP_X_ASSIGN] = icondb.cupXassign
this.reg[TID_ACTUATOR_CUP_Y_ASSIGN] = icondb.cupYassign
this.reg[TID_ACTUATOR_CUP_Z_ASSIGN] = icondb.cupZassign
this.reg[TID_MODIFIER_CUP_X_READ] = icondb.cupXread
this.reg[TID_MODIFIER_CUP_Y_READ] = icondb.cupYread
this.reg[TID_MODIFIER_CUP_Z_READ] = icondb.cupZread

// numbers
this.reg[TID_MODIFIER_RANDOM_TOSS] = icondb.diceToss
this.reg[TID_FILTER_COIN_1] = icondb.blocks1
this.reg[TID_FILTER_COIN_2] = icondb.blocks2
this.reg[TID_FILTER_COIN_3] = icondb.blocks3
this.reg[TID_FILTER_COIN_4] = icondb.blocks4
this.reg[TID_FILTER_COIN_5] = icondb.blocks5
this.reg[TID_MODIFIER_COIN_1] = icondb.blocks1
this.reg[TID_MODIFIER_COIN_2] = icondb.blocks2
this.reg[TID_MODIFIER_COIN_3] = icondb.blocks3
this.reg[TID_MODIFIER_COIN_4] = icondb.blocks4
this.reg[TID_MODIFIER_COIN_5] = icondb.blocks5

// micro:bit sensors
this.reg[TID_SENSOR_ACCELEROMETER] = icondb.accelerometer
this.reg[TID_SENSOR_TIMER] = icondb.tile_timer
this.reg[TID_SENSOR_RADIO_RECEIVE] = icondb.radio_receive
this.reg[TID_SENSOR_PRESS] = icondb.finger_press
this.reg[TID_SENSOR_RELEASE] = icondb.finger_release
this.reg[TID_SENSOR_MICROPHONE] = icondb.microphone
this.reg[TID_SENSOR_ACCELEROMETER] = icondb.accelerometer
this.reg[TID_SENSOR_CUP_X_WRITTEN] = icondb.cupXwritten
this.reg[TID_SENSOR_CUP_Y_WRITTEN] = icondb.cupYwritten
this.reg[TID_SENSOR_CUP_Z_WRITTEN] = icondb.cupZwritten
this.reg[TID_SENSOR_MAGNET] = icondb.magnet
this.reg[TID_SENSOR_SLIDER] = icondb.kita_slider
this.reg[TID_SENSOR_ROTARY] = icondb.kita_rotary
this.reg[TID_SENSOR_TEMP] = icondb.thermometer
this.reg[TID_SENSOR_LIGHT] = icondb.light_sensor
this.reg[TID_SENSOR_START_PAGE] = icondb.tile_start_page

// filters
// micro:bit filters
this.reg[TID_FILTER_LOGO] = icondb.microbit_logo
this.reg[TID_FILTER_PIN_0] = icondb.tile_pin_0
this.reg[TID_FILTER_PIN_1] = icondb.tile_pin_1
this.reg[TID_FILTER_PIN_2] = icondb.tile_pin_2
this.reg[TID_FILTER_BUTTON_A] = icondb.tile_button_a
this.reg[TID_FILTER_BUTTON_B] = icondb.tile_button_b
this.reg[TID_FILTER_KITA_KEY_1] = icondb.kita_key_1
this.reg[TID_FILTER_KITA_KEY_2] = icondb.kita_key_2

this.reg[TID_FILTER_TIMESPAN_SHORT] = icondb.tile_timespan_short
this.reg[TID_FILTER_TIMESPAN_LONG] = icondb.tile_timespan_long
this.reg[TID_FILTER_TIMESPAN_VERY_LONG] =
icondb.tile_timespan_fiveSeconds
this.reg[TID_FILTER_TIMESPAN_RANDOM] = icondb.tile_timespan_random
this.reg[TID_FILTER_COIN_1] = icondb.blocks1
this.reg[TID_FILTER_COIN_2] = icondb.blocks2
this.reg[TID_FILTER_COIN_3] = icondb.blocks3
this.reg[TID_FILTER_COIN_4] = icondb.blocks4
this.reg[TID_FILTER_COIN_5] = icondb.blocks5
this.reg[TID_FILTER_LOUD] = icondb.speaker
this.reg[TID_FILTER_QUIET] = icondb.speakerQuiet
this.reg[TID_FILTER_CUP_X_READ] = icondb.cupXread
this.reg[TID_FILTER_CUP_Y_READ] = icondb.cupYread
this.reg[TID_FILTER_CUP_Z_READ] = icondb.cupZread
this.reg[TID_FILTER_ROTARY_LEFT] = icondb.kita_rotary_left
this.reg[TID_FILTER_ROTARY_RIGHT] = icondb.kita_rotary_right
this.reg[TID_FILTER_TEMP_WARMER] = icondb.temp_warmer
this.reg[TID_FILTER_TEMP_COLDER] = icondb.temp_colder
this.reg[TID_FILTER_ACCEL_SHAKE] = icondb.moveShake
this.reg[TID_FILTER_ACCEL_TILT_UP] = icondb.moveTiltUp
this.reg[TID_FILTER_ACCEL_TILT_DOWN] = icondb.moveTiltDown
this.reg[TID_FILTER_ACCEL_TILT_LEFT] = icondb.moveTiltLeft
this.reg[TID_FILTER_ACCEL_TILT_RIGHT] = icondb.moveTiltRight

// actuators
this.reg[TID_ACTUATOR_SWITCH_PAGE] = icondb.tile_switch_page
// micro:bit actuators
this.reg[TID_ACTUATOR_PAINT] = icondb.showScreen
this.reg[TID_ACTUATOR_SHOW_NUMBER] = icondb.showNumber
this.reg[TID_ACTUATOR_RADIO_SEND] = icondb.radio_send
this.reg[TID_ACTUATOR_RADIO_SET_GROUP] = icondb.radio_set_group
this.reg[TID_ACTUATOR_MICROPHONE] = icondb.microphone
this.reg[TID_ACTUATOR_SPEAKER] = icondb.speakerFun
this.reg[TID_ACTUATOR_MUSIC] = icondb.music
this.reg[TID_ACTUATOR_RGB_LED] = icondb.rgbLed
this.reg[TID_ACTUATOR_CUP_X_ASSIGN] = icondb.cupXassign
this.reg[TID_ACTUATOR_CUP_Y_ASSIGN] = icondb.cupYassign
this.reg[TID_ACTUATOR_CUP_Z_ASSIGN] = icondb.cupZassign

// modifiers
// micro:bit modifiers
this.reg[TID_MODIFIER_ICON_EDITOR] = icondb.iconEditor
this.reg[TID_MODIFIER_MELODY_EDITOR] = icondb.melodyEditor
this.reg[TID_MODIFIER_RANDOM_TOSS] = icondb.diceToss
this.reg[TID_MODIFIER_LOOP] = icondb.loop

this.reg[TID_MODIFIER_PAGE_1] = icondb.tile_page_1
this.reg[TID_MODIFIER_PAGE_2] = icondb.tile_page_2
this.reg[TID_MODIFIER_PAGE_3] = icondb.tile_page_3
this.reg[TID_MODIFIER_PAGE_4] = icondb.tile_page_4
this.reg[TID_MODIFIER_PAGE_5] = icondb.tile_page_5

this.reg[TID_MODIFIER_COIN_1] = icondb.blocks1
this.reg[TID_MODIFIER_COIN_2] = icondb.blocks2
this.reg[TID_MODIFIER_COIN_3] = icondb.blocks3
this.reg[TID_MODIFIER_COIN_4] = icondb.blocks4
this.reg[TID_MODIFIER_COIN_5] = icondb.blocks5

this.reg[TID_MODIFIER_RGB_LED_COLOR_1] = icondb.tile_color_red
this.reg[TID_MODIFIER_RGB_LED_COLOR_2] = icondb.tile_color_green
this.reg[TID_MODIFIER_RGB_LED_COLOR_3] = icondb.tile_color_blue
this.reg[TID_MODIFIER_RGB_LED_COLOR_4] = icondb.tile_color_magenta
this.reg[TID_MODIFIER_RGB_LED_COLOR_5] = icondb.tile_color_yellow
this.reg[TID_MODIFIER_RGB_LED_COLOR_6] = icondb.tile_color_black

this.reg[TID_MODIFIER_RGB_LED_COLOR_RAINBOW] = icondb.tile_rainbow
this.reg[TID_MODIFIER_RGB_LED_COLOR_SPARKLE] = icondb.tile_sparkle

this.reg[TID_MODIFIER_SERVO_SET_ANGLE] = icondb.servo_set_angle

this.reg[TID_MODIFIER_EMOJI_GIGGLE] = icondb.soundGiggle
this.reg[TID_MODIFIER_EMOJI_HAPPY] = icondb.soundHappy
Expand All @@ -168,17 +197,7 @@ namespace microcode {
this.reg[TID_MODIFIER_EMOJI_TWINKLE] = icondb.soundTwinkle
this.reg[TID_MODIFIER_EMOJI_YAWN] = icondb.soundYawn

this.reg[TID_MODIFIER_CUP_X_READ] = icondb.cupXread
this.reg[TID_MODIFIER_CUP_Y_READ] = icondb.cupYread
this.reg[TID_MODIFIER_CUP_Z_READ] = icondb.cupZread
this.reg[TID_MODIFIER_TEMP_READ] = icondb.thermometer

this.reg[TID_FILTER_ACCEL_SHAKE] = icondb.moveShake
this.reg[TID_FILTER_ACCEL_TILT_UP] = icondb.moveTiltUp
this.reg[TID_FILTER_ACCEL_TILT_DOWN] = icondb.moveTiltDown
this.reg[TID_FILTER_ACCEL_TILT_LEFT] = icondb.moveTiltLeft
this.reg[TID_FILTER_ACCEL_TILT_RIGHT] = icondb.moveTiltRight

this.reg[TID_MODIFIER_RADIO_VALUE] = icondb.radio_value
}
}
Expand Down Expand Up @@ -2896,6 +2915,140 @@ bffffffffffffffffffffffffffffffb
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
`


export const car = img`
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . f f f f f f f f . . . .
. . . f f 1 1 1 1 1 1 f f . . .
. . f f 1 1 1 1 1 1 1 1 f f . .
. . f f 1 1 1 1 1 1 1 1 f f . .
. . f f 1 1 1 1 1 1 1 1 f f . .
. f f f f f f f f f f f f f f .
. f f 9 f f f f f f f f 9 f f .
. f 9 1 9 f f f f f f 9 1 9 f .
. f f 9 f f f f f f f f 9 f f .
. f f f f f f f f f f f f f f .
. . f f . . . . . . . . f f . .
. . f f . . . . . . . . f f . .
. . f f . . . . . . . . f f . .
. . . . . . . . . . . . . . . .
`

export const car_forward = img`
. . . . . . . . . . . . . . . .
. . . . . . . c . . . . . . . .
. . . . . . c 7 c . . . . . . .
. . . . . c 7 7 7 c . . . . . .
. . . . c 7 7 7 7 7 c . . . . .
. . . c 7 7 7 7 7 7 7 c . . . .
. . . c 7 7 7 7 7 7 7 c . . . .
. . . c c c 7 7 7 c c c . . . .
. . . . . c 7 7 7 c . . . . . .
. . . . . c 7 7 7 c . . . . . .
. . . . . c 7 7 7 c . . . . . .
. . . . . c 7 7 7 c . . . . . .
. . . . . c 7 7 7 c . . . . . .
. . . . . c c c c c . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
`

export const car_reverse = img`
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . c c c c c . . . . .
. . . . . . c 7 7 7 c . . . . .
. . . . . . c 7 7 7 c . . . . .
. . . . . . c 7 7 7 c . . . . .
. . . . . . c 7 7 7 c . . . . .
. . . . . . c 7 7 7 c . . . . .
. . . . c c c 7 7 7 c c c . . .
. . . . c 7 7 7 7 7 7 7 c . . .
. . . . c 7 7 7 7 7 7 7 c . . .
. . . . . c 7 7 7 7 7 c . . . .
. . . . . . c 7 7 7 c . . . . .
. . . . . . . c 7 c . . . . . .
. . . . . . . . c . . . . . . .
. . . . . . . . . . . . . . . .
`

export const car_left_turn = img`
. . . . . . . . . . . . . . . .
. . . . . c c c . . . . . . . .
. . . . c 7 7 c . . . . . . . .
. . . c 7 7 7 c c c c . . . . .
. . c 7 7 7 7 7 7 7 7 c . . . .
. c 7 7 7 7 7 7 7 7 7 7 c . . .
. . c 7 7 7 7 7 7 7 7 7 7 c . .
. . . c 7 7 7 c c 7 7 7 7 7 c .
. . . . c 7 7 c . c 7 7 7 7 c .
. . . . . c c c . . c 7 7 7 c .
. . . . . . . . . . c 7 7 7 c .
. . . . . . . . . . c 7 7 7 c .
. . . . . . . . . . c 7 7 7 c .
. . . . . . . . . . c 7 7 7 c .
. . . . . . . . . . c c c c c .
. . . . . . . . . . . . . . . .
`

export const car_right_turn = img`
. . . . . . . . . . . . . . . .
. . . . . . . . c c c . . . . .
. . . . . . . . c 7 7 c . . . .
. . . . . c c c c 7 7 7 c . . .
. . . . c 7 7 7 7 7 7 7 7 c . .
. . . c 7 7 7 7 7 7 7 7 7 7 c .
. . c 7 7 7 7 7 7 7 7 7 7 c . .
. c 7 7 7 7 7 c c 7 7 7 c . . .
. c 7 7 7 7 c . c 7 7 c . . . .
. c 7 7 7 c . . c c c . . . . .
. c 7 7 7 c . . . . . . . . . .
. c 7 7 7 c . . . . . . . . . .
. c 7 7 7 c . . . . . . . . . .
. c 7 7 7 c . . . . . . . . . .
. c c c c c . . . . . . . . . .
. . . . . . . . . . . . . . . .
`

export const car_stop = img`
. . . . . . . . . . . . . . . .
. . . . . 1 1 1 1 1 1 . . . . .
. . . . 1 2 2 2 2 2 2 1 . . . .
. . . 1 2 2 2 2 2 2 2 2 1 . . .
. . 1 2 2 2 2 2 2 2 2 2 2 1 . .
. 1 2 2 2 2 2 2 2 2 2 2 2 2 1 .
. 1 2 2 2 2 2 2 2 2 2 2 2 2 1 .
. 1 2 2 2 2 2 2 2 2 2 2 2 2 1 .
. 1 2 2 2 2 2 2 2 2 2 2 2 2 1 .
. 1 2 2 2 2 2 2 2 2 2 2 2 2 1 .
. 1 2 2 2 2 2 2 2 2 2 2 2 2 1 .
. . 1 2 2 2 2 2 2 2 2 2 2 1 . .
. . . 1 2 2 2 2 2 2 2 2 1 . . .
. . . . 1 2 2 2 2 2 2 1 . . . .
. . . . . 1 1 1 1 1 1 . . . . .
. . . . . . . . . . . . . . . .
`

export const car_wall = img`
. . . . . . . . . . . . . . . .
b b b b b b b b b b b b b b b b
2 2 2 2 b 2 2 2 2 b 2 2 2 2 b 2
2 2 2 2 b 2 2 2 2 b 2 2 2 2 b 2
b b b b b b b b b b b b b b b b
2 2 b 2 2 2 2 b 2 2 2 2 b 2 2 2
2 2 b 2 2 2 2 b 2 2 2 2 b 2 2 2
b b b b b b b b b b b b b b b b
2 2 2 2 b 2 2 2 2 b 2 2 2 2 b 2
2 2 2 2 b 2 2 2 2 b 2 2 2 2 b 2
b b b b b b b b b b b b b b b b
2 2 b 2 2 2 2 b 2 2 2 2 b 2 2 2
2 2 b 2 2 2 2 b 2 2 2 2 b 2 2 2
b b b b b b b b b b b b b b b b
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
`

/* maybe use these later
export const rc_high = img`
Expand Down
1 change: 1 addition & 0 deletions config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ namespace userconfig {
namespace microcode {
export const ERROR_NOT_INTEGER = 101
export const ERROR_DOUBLE_BACKGROUND_CAPTURE = 102
export const car_tiles = false
}
Loading

0 comments on commit 496c3e9

Please sign in to comment.