You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
133 lines
3.9 KiB
133 lines
3.9 KiB
/* Includes */ |
|
#include <stdio.h> |
|
#include "pico/stdlib.h" |
|
#include "pico/rand.h" |
|
#include "hardware/spi.h" |
|
#include "hardware/dma.h" |
|
#include "hardware/pio.h" |
|
#include "epd0.h" |
|
#include "epd/epd_4p2mono.h" |
|
|
|
/* Global Variables */ |
|
epd_dbuf_t epd0_dbuf[EPD_4P2MONO_WIDTH * EPD_4P2MONO_HEIGHT / 8]; |
|
|
|
/* Function Definitions */ |
|
static inline void spi_cs_assert() |
|
{ |
|
gpio_put(EPD0_PIN_CS, 0); |
|
} |
|
static inline void spi_cs_deassert() |
|
{ |
|
gpio_put(EPD0_PIN_CS, 1); |
|
} |
|
static inline void spi_write_byte(uint8_t b) |
|
{ |
|
spi_cs_assert(); |
|
spi_write_blocking(EPD0_SPI_PORT, &b, 1); |
|
spi_cs_deassert(); |
|
} |
|
static inline void spi_read_busy() |
|
{ |
|
do |
|
{ |
|
spi_write_byte(0x71); |
|
} |
|
while (gpio_get(EPD0_PIN_BUSY)); |
|
} |
|
|
|
int main() |
|
{ |
|
uint16_t i; |
|
uint16_t j; |
|
absolute_time_t t; |
|
|
|
stdio_init_all(); |
|
|
|
epd0_init(); |
|
epd_4p2mono_init(&epd0); |
|
epd_dbuf_set(&epd0, epd0_dbuf); |
|
|
|
epd_4p2mono_clear(&epd0); |
|
epd_4p2mono_testpattern(&epd0); |
|
epd_4p2mono_testimg(&epd0); |
|
sleep_ms(2000); |
|
|
|
epd_draw_line(&epd0, 152, 0, 96, EPD_DIR_L2R); |
|
epd_draw_line(&epd0, 152, 1, 96, EPD_DIR_L2R); |
|
epd_draw_line(&epd0, 152, 3, 96, EPD_DIR_L2R); |
|
epd_draw_line(&epd0, 152, 7, 96, EPD_DIR_L2R); |
|
epd_draw_line(&epd0, 152, 15, 96, EPD_DIR_L2R); |
|
epd_draw_line(&epd0, 152, 31, 96, EPD_DIR_L2R); |
|
epd_draw_line(&epd0, 152, 63, 96, EPD_DIR_L2R); |
|
epd_draw_line(&epd0, 152, 127, 96, EPD_DIR_L2R); |
|
epd_draw_line(&epd0, 152, 0, 128, EPD_DIR_T2B); |
|
epd_draw_line(&epd0, 153, 1, 127, EPD_DIR_T2B); |
|
epd_draw_line(&epd0, 155, 3, 125, EPD_DIR_T2B); |
|
epd_draw_line(&epd0, 159, 7, 121, EPD_DIR_T2B); |
|
epd_draw_line(&epd0, 167, 15, 113, EPD_DIR_T2B); |
|
epd_draw_line(&epd0, 183, 31, 97, EPD_DIR_T2B); |
|
epd_draw_line(&epd0, 215, 63, 65, EPD_DIR_T2B); |
|
for(i = 0; i < 100; i += 10) |
|
{ |
|
for(j = 0; j < 8; j++) |
|
{ |
|
epd_draw_line(&epd0, 100 + i + j, 160 + (2 * j), 8 - j, EPD_DIR_L2R); |
|
} |
|
} |
|
for(i = 0; i < 14; i ++) |
|
{ |
|
epd_draw_line(&epd0, 96 + (i * 8), 158, 20, EPD_DIR_T2B); |
|
} |
|
epd_draw_line(&epd0, 100, 200, 100, EPD_DIR_L2R); |
|
epd_draw_line(&epd0, 101, 202, 100, EPD_DIR_L2R); |
|
epd_draw_line(&epd0, 102, 204, 100, EPD_DIR_L2R); |
|
epd_draw_line(&epd0, 103, 206, 100, EPD_DIR_L2R); |
|
epd_draw_line(&epd0, 104, 208, 100, EPD_DIR_L2R); |
|
epd_draw_line(&epd0, 105, 210, 100, EPD_DIR_L2R); |
|
epd_draw_line(&epd0, 106, 212, 100, EPD_DIR_L2R); |
|
epd_draw_line(&epd0, 107, 214, 100, EPD_DIR_L2R); |
|
epd_draw_line(&epd0, 153, 182, 50, EPD_DIR_T2B); |
|
epd_draw_line(&epd0, 155, 231, 50, EPD_DIR_B2T); |
|
epd0.fontdata.decode.is_transparent = 1; |
|
epd_font_set(&epd0, epd_font_inr21_mf); |
|
epd_draw_str(&epd0, 20, 40, "u8g2 is NFG"); |
|
epd_font_set(&epd0, epd_font_haxrcorp4089_tr); |
|
epd_draw_str(&epd0, 200, 200, "h4x0r"); |
|
epd_font_set(&epd0, epd_font_u8glib_4_tf); |
|
epd_draw_str(&epd0, 320, 250, "1337"); |
|
epd_font_set(&epd0, epd_font_haxrcorp4089_tr); |
|
epd_draw_str(&epd0, 0, 264, "The quick, brown fox jumped over the lazy dog."); |
|
epd_font_set(&epd0, epd_font_profont11_mf); |
|
epd_draw_str(&epd0, 0, 280, "The quick, brown fox jumped over the lazy dog."); |
|
epd_font_set(&epd0, epd_font_unifont_t_extended); |
|
epd_draw_str(&epd0, 0, 296, "The quick, brown fox jumped over the lazy dog."); |
|
epd_font_set(&epd0, epd_font_inr21_mf); |
|
epd_draw_str(&epd0, 250, 154, "Sigma-wrapped text."); |
|
epd_update(&epd0); |
|
sleep_ms(2000); |
|
|
|
t = make_timeout_time_ms(180000); /* full screen refresh every 180 s */ |
|
for (;;) |
|
{ |
|
uint32_t x; |
|
uint32_t y; |
|
|
|
x = get_rand_32() % EPD_4P2MONO_WIDTH; |
|
y = (get_rand_32() % (EPD_4P2MONO_HEIGHT - 28) + 23); |
|
|
|
//epd_dbuf_clear(&epd0); |
|
epd_font_set(&epd0, epd_font_inr21_mf); |
|
epd_draw_str(&epd0, x, y, "Sigma-wrapped text."); |
|
//epd_update(&epd0); |
|
/* FIXME: should accept width in pixels and convert to bytes internally */ |
|
epd_update_partial(&epd0, x % 100, x, y < 23 ? 0 : y - 23, y + 5); |
|
//sleep_ms(1000); |
|
if(absolute_time_diff_us(t, get_absolute_time()) > 0) |
|
{ |
|
epd_update(&epd0); |
|
t = make_timeout_time_ms(180000); |
|
} |
|
} |
|
|
|
return 0; |
|
}
|
|
|