From 168ea4b5641eb08ef24c70e94e332aaabf7e2e81 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Tue, 13 Apr 2021 08:31:21 +0200 Subject: add ssd1306 bad apple skeleton --- src/app/ssd1306-bad-apple/main.cc | 74 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 src/app/ssd1306-bad-apple/main.cc (limited to 'src/app/ssd1306-bad-apple/main.cc') diff --git a/src/app/ssd1306-bad-apple/main.cc b/src/app/ssd1306-bad-apple/main.cc new file mode 100644 index 0000000..5e89625 --- /dev/null +++ b/src/app/ssd1306-bad-apple/main.cc @@ -0,0 +1,74 @@ +/* + * Copyright 2020 Daniel Friesel + * + * SPDX-License-Identifier: BSD-2-Clause + */ +#include "arch.h" +#include "driver/gpio.h" +#include "driver/stdout.h" +#include "driver/i2c.h" +#include "driver/ssd1306.h" +#include "lib/inflate.h" + +#include "driver/timer.h" +volatile unsigned char timer_done = 0; + +#include "frames.cc" + +__attribute__((section(".leaRAM"))) unsigned char img_buf[(128 * 64 / 8) * 3]; + +int main(void) +{ + unsigned int i = 0; + unsigned char line; + arch.setup(); + gpio.setup(); + kout.setup(); + i2c.setup(); + ssd1306.init(); + + timer.setup_hz_low(frame_rate); + + while (1) { + for (i = 0; i < (sizeof(frames) / sizeof(frames[0])); i++) { + + timer_done = 0; + timer.start(1); + + ssd1306.showImage(img_buf + (128 * 64 / 8 * 2), 128 * 64 / 8); + + inflate(frames[i], sizeof(img_buf), img_buf, sizeof(img_buf)); + + while (!timer_done) { + arch.idle(); + } + timer.stop(); + + timer_done = 0; + timer.start(1); + + ssd1306.showImage(img_buf + (128 * 64 / 8 * 0), 128 * 64 / 8); + + while (!timer_done) { + arch.idle(); + } + timer.stop(); + + timer_done = 0; + timer.start(1); + + ssd1306.showImage(img_buf + (128 * 64 / 8 * 1), 128 * 64 / 8); + + while (!timer_done) { + arch.idle(); + } + timer.stop(); + } + } + + return 0; +} + +ON_TIMER_INTERRUPT_head + timer_done = 1; +ON_TIMER_INTERRUPT_tail -- cgit v1.2.3