2 * Copyright © 2023 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
20 #include <ao_st7565.h>
22 #define WIDTH AO_ST7565_WIDTH
23 #define HEIGHT AO_ST7565_HEIGHT
24 #define STRIDE AO_BITMAP_STRIDE(WIDTH)
26 static uint32_t image[STRIDE * HEIGHT];
28 static struct ao_bitmap fb = {
33 .damage = AO_BOX_INIT,
39 ao_rect(&fb, 0, 0, WIDTH, HEIGHT, AO_WHITE, AO_COPY);
40 ao_st7565_update(&fb);
41 ao_text(&fb, &BitstreamVeraSans_Roman_24_font,
42 0, 20, "hello world", AO_BLACK, AO_COPY);
43 ao_st7565_update(&fb);
46 static int16_t x1 = 32, _y1 = 10, x2 = 32, y2 = 40;
47 static int16_t dx1 = 2, dy1 = 2, dx2 = -2, dy2 = -1;
49 #define bounds(v,m,M,d) \
63 for (i = 0; i < 100; i++) {
64 ao_rect(&fb, 0, 0, WIDTH, HEIGHT, AO_WHITE, AO_COPY);
65 ao_line(&fb, x1, _y1, x2, y2, AO_BLACK, AO_COPY);
66 ao_st7565_update(&fb);
71 printf("%d,%d - %d,%d\n", x1, _y1, x2, y2);
73 bounds(x1, 0, WIDTH, dx1);
74 bounds(x2, 0, WIDTH, dx2);
75 bounds(_y1, 0, HEIGHT, dy1);
76 bounds(y2, 0, HEIGHT, dy2);
77 ao_delay(AO_MS_TO_TICKS(200));
81 static const struct ao_transform logo_transform = {
82 .x_scale = 48, .x_off = 0,
83 .y_scale = 48, .y_off = 0,
86 #define LOGO_FONT BenguiatGothicStd_Bold_26_font
91 ao_rect(&fb, 0, 0, WIDTH, HEIGHT, AO_WHITE, AO_COPY);
92 ao_logo(&fb, &logo_transform, &LOGO_FONT, 0x00000000, AO_COPY);
93 ao_st7565_update(&fb);
96 const struct ao_cmds ao_st7565_cmds[] = {
97 { ao_st7565_test, "g\0Test ST7565 display" },
98 { ao_st7565_line, "l\0Draw lines" },
99 { ao_st7565_poly, "p\0Draw polygon" },
115 ao_cmd_register(ao_st7565_cmds);
116 ao_start_scheduler();