Skip to content

Commit

Permalink
clear
Browse files Browse the repository at this point in the history
  • Loading branch information
openshwprojects committed Dec 6, 2024
1 parent 504034b commit c96881e
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/driver/drv_st7735.c
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,29 @@ static commandResult_t Cmd_ST7735_Init(const void *context, const char *cmd, con

return CMD_RES_OK;
}
static inline byte hex2dec(char c) {
return (c >= '0' && c <= '9') ? c - '0' : (c >= 'A' && c <= 'F') ? c - 'A' + 10 : 0;
}

static commandResult_t CMD_ST7735_Clear(const void *context, const char *cmd, const char *args, int flags) {
Tokenizer_TokenizeString(args, TOKENIZER_ALLOW_QUOTES);

const char *rgbStr = "FFFFFF";
if (Tokenizer_GetArgsCount() > 0) {
rgbStr = Tokenizer_GetArg(0);
}

byte rgb[3] = {
(byte)((hex2dec(rgbStr[0]) << 4) | hex2dec(rgbStr[1])),
(byte)((hex2dec(rgbStr[2]) << 4) | hex2dec(rgbStr[3])),
(byte)((hex2dec(rgbStr[4]) << 4) | hex2dec(rgbStr[5]))
};

int fin = Color565(rgb[0], rgb[1], rgb[2]);
ST7735_fillScreen(fin);
return CMD_RES_OK;
}

/*
startDriver ST7735
ST7735_Init
Expand All @@ -690,6 +713,7 @@ goto again
void ST7735_Init() {
CMD_RegisterCommand("ST7735_Test", CMD_ST7735_Test, NULL);
CMD_RegisterCommand("ST7735_Test2", CMD_ST7735_Test2, NULL);
CMD_RegisterCommand("ST7735_Clear", CMD_ST7735_Clear, NULL);
CMD_RegisterCommand("ST7735_Init", Cmd_ST7735_Init, NULL);

}
Expand Down

0 comments on commit c96881e

Please sign in to comment.