upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
Diffstat (limited to 'components')
-rw-r--r--components/axs15231b/axs15231b.c32
-rw-r--r--components/axs15231b/include/axs15231b.h1
2 files changed, 33 insertions, 0 deletions
diff --git a/components/axs15231b/axs15231b.c b/components/axs15231b/axs15231b.c
index 7424a20..77708dd 100644
--- a/components/axs15231b/axs15231b.c
+++ b/components/axs15231b/axs15231b.c
@@ -37,6 +37,7 @@ static spi_device_handle_t s_spi = NULL;
37static uint16_t *s_fb = NULL; 37static uint16_t *s_fb = NULL;
38static int s_width = AXS15231B_WIDTH; 38static int s_width = AXS15231B_WIDTH;
39static int s_height = AXS15231B_HEIGHT; 39static int s_height = AXS15231B_HEIGHT;
40static int s_rotation = 0;
40static uint8_t *s_swap_buf = NULL; 41static uint8_t *s_swap_buf = NULL;
41#define SWAP_BUF_PIXELS 2048 42#define SWAP_BUF_PIXELS 2048
42 43
@@ -354,3 +355,34 @@ void axs15231b_flush(void) {
354 355
355int axs15231b_get_width(void) { return s_width; } 356int axs15231b_get_width(void) { return s_width; }
356int axs15231b_get_height(void) { return s_height; } 357int axs15231b_get_height(void) { return s_height; }
358
359void axs15231b_set_rotation(int rotation) {
360 uint8_t madctl = MADCTL_RGB;
361 switch (rotation) {
362 case 0:
363 madctl = MADCTL_RGB;
364 s_width = AXS15231B_WIDTH;
365 s_height = AXS15231B_HEIGHT;
366 break;
367 case 1:
368 madctl = MADCTL_MX | MADCTL_MV;
369 s_width = AXS15231B_HEIGHT;
370 s_height = AXS15231B_WIDTH;
371 break;
372 case 2:
373 madctl = MADCTL_MX | MADCTL_MY;
374 s_width = AXS15231B_WIDTH;
375 s_height = AXS15231B_HEIGHT;
376 break;
377 case 3:
378 madctl = MADCTL_MY | MADCTL_MV;
379 s_width = AXS15231B_HEIGHT;
380 s_height = AXS15231B_WIDTH;
381 break;
382 default:
383 return;
384 }
385 s_rotation = rotation;
386 qspi_write_cmd_data8(MADCTL, madctl);
387 ESP_LOGI(TAG, "Rotation set to %d (%dx%d)", rotation, s_width, s_height);
388}
diff --git a/components/axs15231b/include/axs15231b.h b/components/axs15231b/include/axs15231b.h
index cddea98..a8c1a37 100644
--- a/components/axs15231b/include/axs15231b.h
+++ b/components/axs15231b/include/axs15231b.h
@@ -23,5 +23,6 @@ void axs15231b_fill_rect(int x, int y, int w, int h, uint16_t color);
23void axs15231b_flush(void); 23void axs15231b_flush(void);
24int axs15231b_get_width(void); 24int axs15231b_get_width(void);
25int axs15231b_get_height(void); 25int axs15231b_get_height(void);
26void axs15231b_set_rotation(int rotation);
26 27
27#endif 28#endif