Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated commands to get current cursor position #118

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions duckyscript3_beta_test.md
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,14 @@ Returns 0 if no key is pressed. 1 to 17 otherwise.

Get how many times the current key has been pressed.

#### `$_CURSORX` (RO)

Returns current X position of cursor on OLED screen.

#### `$_CURSORY` (RO)

Returns current Y position of cursor on OLED screen.

## Reading Buttons

Reading the reserved variable `$_READKEY` returns the currently pressed key.
Expand Down
2 changes: 2 additions & 0 deletions firmware/code_duckyscript3/Inc/ds3_vm.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@
#define _LOOP_SIZE (0xffff - 8)
#define _KEYPRESS_COUNT (0xffff - 9)
#define _NEEDS_EPILOGUE (0xffff - 10)
#define _CURSORX (0xffff - 11)
#define _CURSORY (0xffff - 12)

typedef struct
{
Expand Down
1 change: 1 addition & 0 deletions firmware/code_duckyscript3/Inc/ssd1306.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,6 @@ void ssd1306_SetCursor(uint8_t x, uint8_t y);
void ssd1306_dim(uint8_t is_dim);

static void ssd1306_WriteCommand(uint8_t command);
extern SSD1306_t SSD1306;

#endif
11 changes: 11 additions & 0 deletions firmware/code_duckyscript3/Src/ds3_vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ uint16_t charjitter_value;
uint16_t rand_min, rand_max;
uint16_t loop_size;
uint8_t epilogue_actions;
uint8_t cursor_x;
uint8_t cursor_y;
extern SSD1306_t SSD1306;

typedef struct
{
Expand Down Expand Up @@ -159,6 +162,10 @@ void write_var(uint16_t addr, uint16_t value)
; // this is read only, so do nothing
else if (addr == _NEEDS_EPILOGUE)
epilogue_actions = value; // this is read only, so do nothing
else if (addr == _CURSORX)
cursor_x = value; // this is read only, so do nothing
else if (addr == _CURSORY)
cursor_y = value; // this is read only, so do nothing
else if(addr < VAR_BUF_SIZE)
store_uint16_as_two_bytes_at(addr, value);
}
Expand Down Expand Up @@ -189,6 +196,10 @@ uint16_t read_var(uint16_t addr)
return key_press_count[current_key];
else if (addr == _NEEDS_EPILOGUE)
return epilogue_actions;
else if (addr == _CURSORX)
return SSD1306.CurrentX;
else if (addr == _CURSORY)
return SSD1306.CurrentY;
else if(addr < VAR_BUF_SIZE)
return make_uint16(var_buf[addr], var_buf[addr+1]);
return 0;
Expand Down
2 changes: 1 addition & 1 deletion firmware/code_duckyscript3/Src/ssd1306.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion pc_software/duckyscript3/keywords.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,4 +389,6 @@ def replace_DEFINE(pgm_line, dd):
"_LOOP_SIZE": (0xffff - 8),
"_KEYPRESS_COUNT": (0xffff - 9),
"_NEEDS_EPILOGUE": (0xffff - 10),
}
"_CURSORX": (0xffff - 11),
"_CURSORY": (0xffff - 12)
}