From bc4baf38ba66d5aa80381f08ab395af503480279 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Mon, 30 Nov 2020 13:38:05 -0500 Subject: low-power improvements; starting flappy bird --- dogs.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'dogs.c') diff --git a/dogs.c b/dogs.c index a2d3baf..65a34e7 100644 --- a/dogs.c +++ b/dogs.c @@ -136,7 +136,7 @@ void dogs_init_display() CS_LOW; dogs_reset(); CS_HIGH; - chThdSleepMilliseconds(100); + chThdSleepS(TIME_MS2I(100) / 64); CS_LOW; dogs_set_scroll_line(0); dogs_set_segdir(true); @@ -146,7 +146,7 @@ void dogs_init_display() dogs_set_bias(true); dogs_set_power(0x07); dogs_set_vlcd_ratio(7); - dogs_set_contrast(0x10); + dogs_set_contrast(12); dogs_set_advanced(0x83); dogs_set_sleep(false); CS_HIGH; @@ -187,12 +187,22 @@ void dogs_flush() void draw_pixel(int x, int y, bool state) { + if (x < 0 || y < 0 || x >= DISP_WIDTH || y >= DISP_HEIGHT) + return; if (state) dogs_buffer[y / 8 * DISP_WIDTH + x] |= (1 << (y % 8)); else dogs_buffer[y / 8 * DISP_WIDTH + x] &= ~(1 << (y % 8)); } +void draw_rect(int x, int y, int w, int h) +{ + for (int i = 0; i < w; i++) { + for (int j = 0; j < h; j++) + draw_pixel(x + i, y + j, true); + } +} + void draw_bitmap(int x, int y, const unsigned char *buffer) { // Prepare source information -- cgit v1.2.3