diff --git a/firmware/beta_1.1.2_duckyscript3img.dfu b/firmware/beta_1.1.2_duckyscript3img.dfu index d2e7fd08..1dc3409c 100644 Binary files a/firmware/beta_1.1.2_duckyscript3img.dfu and b/firmware/beta_1.1.2_duckyscript3img.dfu differ diff --git a/firmware/code_duckyscript3/Src/ds3_vm.c b/firmware/code_duckyscript3/Src/ds3_vm.c index 026acb1a..1a5beb41 100644 --- a/firmware/code_duckyscript3/Src/ds3_vm.c +++ b/firmware/code_duckyscript3/Src/ds3_vm.c @@ -27,6 +27,8 @@ uint16_t rand_min, rand_max; uint16_t loop_size; uint8_t epilogue_actions; +extern SSD1306_t SSD1306; + extern uint8_t hid_tx_buf[HID_TX_BUF_SIZE]; typedef struct @@ -598,6 +600,19 @@ void execute_instruction(uint16_t curr_pc, ds3_exe_result* exe, uint8_t keynum) ssd1306_UpdateScreen(); f_close(&image_file); } + else if (this_opcode == OP_SMB) + { + char* str_buf = make_str(op_data); + for (int y=0; y9) break; + for (int x=0; x<6; x++) { + if (((str_buf[y] - '0') >> (5-x)) & 0x1) { + ssd1306_DrawPixel(SSD1306.CurrentX+x, SSD1306.CurrentY+y, White); + } + } + } + SSD1306.CurrentX += 6; + } else if(this_opcode == OP_OLU) { diff --git a/firmware/code_duckyscript3/Src/ssd1306.c b/firmware/code_duckyscript3/Src/ssd1306.c index 73d0592e..cd47c913 100644 --- a/firmware/code_duckyscript3/Src/ssd1306.c +++ b/firmware/code_duckyscript3/Src/ssd1306.c @@ -33,7 +33,7 @@ static uint8_t SSD1306_Buffer[SSD1306_WIDTH * SSD1306_HEIGHT / 8]; // Een scherm-object om lokaal in te werken -static SSD1306_t SSD1306; +SSD1306_t SSD1306; uint8_t i2c_status; uint8_t last_dim; diff --git a/pc_software/duckyscript3/ds_syntax_check.py b/pc_software/duckyscript3/ds_syntax_check.py index 29bf0177..957fb784 100644 --- a/pc_software/duckyscript3/ds_syntax_check.py +++ b/pc_software/duckyscript3/ds_syntax_check.py @@ -8,7 +8,7 @@ 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~'] mouse_commands = [cmd_LMOUSE, cmd_RMOUSE, cmd_MMOUSE, cmd_MOUSE_MOVE, cmd_MOUSE_WHEEL] -ignored_but_valid_commands = [cmd_UARTPRINT, cmd_LCR, cmd_REM, cmd_DP_SLEEP, cmd_PREV_PROFILE, cmd_NEXT_PROFILE, cmd_INJECT_MOD, cmd_SEND_HID, cmd_IMG] +ignored_but_valid_commands = [cmd_UARTPRINT, cmd_LCR, cmd_REM, cmd_DP_SLEEP, cmd_PREV_PROFILE, cmd_NEXT_PROFILE, cmd_INJECT_MOD, cmd_SEND_HID, cmd_IMG, cmd_SMB] def is_ignored_but_valid_command(ducky_line): for item in ignored_but_valid_commands: diff --git a/pc_software/duckyscript3/keywords.py b/pc_software/duckyscript3/keywords.py index 4e7923bd..c9704b7f 100644 --- a/pc_software/duckyscript3/keywords.py +++ b/pc_software/duckyscript3/keywords.py @@ -16,6 +16,7 @@ cmd_DP_SLEEP = "DP_SLEEP" cmd_SEND_HID = "SEND_HID" cmd_IMG = "IMG" +cmd_SMB = "SMB" cmd_PREV_PROFILE = "PREV_PROFILE" cmd_NEXT_PROFILE = "NEXT_PROFILE" cmd_GOTO_PROFILE = "GOTO_PROFILE" diff --git a/pc_software/duckyscript3/make_bytecode.py b/pc_software/duckyscript3/make_bytecode.py index 8aef878a..f55ab31e 100644 --- a/pc_software/duckyscript3/make_bytecode.py +++ b/pc_software/duckyscript3/make_bytecode.py @@ -66,6 +66,7 @@ OP_SLEEP = ("SLEEP", 47) OP_HID = ("HID", 48) OP_IMG = ("IMG", 49) +OP_SMB = ("SMB", 50) arith_lookup = { "Eq" : OP_EQ, @@ -533,7 +534,7 @@ def make_dsb(program_listing): this_instruction['opcode'] = OP_CALL this_instruction['oparg'] = label_dict[func_lookup[fun_name]['fun_start']] assembly_listing.append(this_instruction) - elif this_line.startswith(cmd_STRING) or first_word == cmd_OLED_PRINT or first_word == cmd_SEND_HID or first_word == cmd_IMG: + elif this_line.startswith(cmd_STRING) or first_word in (cmd_OLED_PRINT, cmd_SEND_HID, cmd_IMG, cmd_SMB): str_content = this_line.split(' ', 1)[-1] if str_content not in str_lookup: str_lookup[str_content] = lnum @@ -547,6 +548,8 @@ def make_dsb(program_listing): this_instruction['opcode'] = OP_HID elif first_word == cmd_IMG: this_instruction['opcode'] = OP_IMG + elif first_word == cmd_SMB: + this_instruction['opcode'] = OP_SMB this_instruction['oparg'] = f"STR@{str_lookup[str_content]}" assembly_listing.append(this_instruction) elif first_word == cmd_DELAY: @@ -695,7 +698,7 @@ def make_dsb(program_listing): label_to_addr_dict[item['label']] = item['addr'] for item in assembly_listing: - if item['opcode'] == OP_STR or item['opcode'] == OP_STRLN or item['opcode'] == OP_OLP or item['opcode'] == OP_HID or item['opcode'] == OP_IMG: + if item['opcode'] in (OP_STR, OP_STRLN, OP_OLP, OP_HID, OP_IMG, OP_SMB): str_lnum = int(item['oparg'].replace('STR@', '')) for sssss in str_list: if sssss['lnum'] == str_lnum: diff --git a/txt2symbol.py b/txt2symbol.py new file mode 100755 index 00000000..4f112d5d --- /dev/null +++ b/txt2symbol.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python +""" +example character definition, note that only the first +10 lines are converted, width may not exceed 6 characters +character = ''' + + oo + o o + oo +''' + +""" +character = ''' + o o + o + ooo + o o + o + o + o o + ooo +''' + +output = '' +for line in character.splitlines()[1:]: + bits = 0 + for pos, x in enumerate(line): + if x != ' ': + bits |= (x != '') << (5-pos) + output += chr(bits + 48) + +print(f'SMB {output[:10]}')