aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main/main.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/main/main.c b/main/main.c
index 97a78b5..34ac38e 100644
--- a/main/main.c
+++ b/main/main.c
@@ -34,8 +34,8 @@ static uint16_t pattern[NUM_ROW][NUM_COL / 8]; // each column is two bits, so 8
void setPixel(uint16_t x, uint16_t y, uint16_t color) {
- pattern[y][x / 8] = pattern[y][x / 8] & ~(0b0000000000000011 << (2 * (x % 8))); // clear this column (note the bitwise inversion)
- pattern[y][x / 8] = pattern[y][x / 8] | (color << (2 * (x % 8))); // write color to column
+ pattern[y][x / 8] = pattern[y][x / 8] & ~(0b0000000000000011 << (14 - (2 * (x % 8)))); // clear this column (note the bitwise inversion)
+ pattern[y][x / 8] = pattern[y][x / 8] | (color << (14 - (2 * (x % 8)))); // write color to column
}
@@ -45,7 +45,7 @@ void drawCharAtPosition(char character, int x_start, int y_start, uint16_t color
cur_char_row = atascii_font[(uint8_t) character][y - y_start];
for(int x = x_start; (x - x_start) < CHAR_WIDTH && x < NUM_COL; x++) {
if(x >= 0) {
- if((1 << (x - x_start)) & cur_char_row) {
+ if((0b10000000 >> (x - x_start)) & cur_char_row) {
setPixel(x, y, color);
}
else {
@@ -149,22 +149,22 @@ void app_main(void)
TaskHandle_t taskHandle;
xTaskCreate(updateDisplay, "updateDisplay", STACK_SIZE, NULL, tskIDLE_PRIORITY, &taskHandle);
- int j = 0;
+ int j = NUM_COL;
+ int color = 1;
+ char* hello = "Hello World!! 0123456789";
+ int hello_length = strlen(hello);
+ int min_x = hello_length * -CHAR_WIDTH;
while(true) {
- ESP_LOGI(TAG, "Writing words...");
-
- char* hello = "Hello World!!";
for(int i = 0; i < strlen(hello); i++) {
- drawCharAtPosition(hello[i], i * CHAR_WIDTH, 0, j % 2 + 1);
+ drawCharAtPosition(hello[i], j + (i * CHAR_WIDTH), 0, color);
}
- char* numbers = "0123456789";
- int offset = strlen(hello) + 1;
- for(int i = 0; i < strlen(numbers); i++) {
- drawCharAtPosition(numbers[i], (i + offset) * CHAR_WIDTH, 0, j % 2 + 2);
+ if(--j == min_x) {
+ j = NUM_COL;
+ if(++color > 3) {
+ color = 1;
+ }
}
-
- j++;
- vTaskDelay(5000 / portTICK_PERIOD_MS);
+ vTaskDelay(50 / portTICK_PERIOD_MS);
}
}