]> code.bitgloo.com Git - clyne/calculator.git/commitdiff
better drawing, landscape
authorClyne Sullivan <tullivan99@gmail.com>
Thu, 15 Feb 2018 13:35:35 +0000 (08:35 -0500)
committerClyne Sullivan <tullivan99@gmail.com>
Thu, 15 Feb 2018 13:35:35 +0000 (08:35 -0500)
include/display.h
include/display_draw.h [new file with mode: 0644]
initrd/init
src/display.c
src/display_draw.c
src/main.c

index 1fab2238fcd7a099a614f1c0943232137ec949a4..fb808c623ba0fc35499f235a1890831a1aa26aa7 100644 (file)
@@ -3,8 +3,8 @@
 
 #include <stdint.h>
 
-#define LCD_WIDTH  320
-#define LCD_HEIGHT 480
+#define LCD_WIDTH  480
+#define LCD_HEIGHT 320
 
 #define COLOR_MAX 31
 
diff --git a/include/display_draw.h b/include/display_draw.h
new file mode 100644 (file)
index 0000000..1030d45
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef DISPLAY_DRAW_H_
+#define DISPLAY_DRAW_H_
+
+void dsp_rect(int x, int y, int w, int h, uint16_t color);
+
+void dsp_cpos(int x, int y);
+void dsp_puts(const char *s);
+
+#endif // DISPLAY_DRAW_H_
index bb0436498716c0258c6c663facf4c5664fd86e29..324e51970683d5afd06e98c56a17a96e252e972c 100644 (file)
@@ -1,10 +1,23 @@
+func div9
+       if ((arg0 % 9) == 0)
+               ret 1
+       end
+       ret 0
+end
+
 set a 0
+set b 0
 do
        set a (a + 1)
+       div9 a > b
+       if (b)
+               print a
+               print ", "
+       end
        delay 1
 while (a < 100)
 
 if (a == 100)
-       print "All good!"
+       print " All good!"
 end
 
index 9600ec086552287606e452d6b47e9c7dd987455a..8b62e6abeb405a03f301eb84adef57c1b9a8df61 100644 (file)
@@ -145,18 +145,10 @@ void dsp_init(void)
        dsp_write_cmd(0xC5); // frame rate/inversion ctl
        dsp_write_data(0x03);
 
-       // backlight
-       dsp_write_cmd(0x55);
-       dsp_write_data(0x01);
-       dsp_write_cmd(0x53);
-       dsp_write_data(0x2C);
-       dsp_write_cmd(0x51);
-       dsp_write_data(0x01);
-
        dsp_write_cmd(0x36); // rot. and stuff
-       dsp_write_data(0x41);
+       dsp_write_data(0xA3);
        dsp_write_cmd(0x3A); // set pixel format
-       dsp_write_data(0x65);
+       dsp_write_data(0x55);
        dsp_write_cmd(0x11);
        delay(150);
        dsp_write_cmd(0x29); // set display on
@@ -171,7 +163,5 @@ void dsp_init(void)
        dsp_write_cmd(0x37);
        dsp_write_data(0x00);
        dsp_write_data(0x00);*/
-
-       dsp_set_addr(0, 0, LCD_WIDTH, LCD_HEIGHT);
 }
 
index 84a5443a012bfc6d3de97c97f72ca07a48c8d13b..f52cd8ea6cf7533dee9155c44eb54141f64b150c 100644 (file)
@@ -17,8 +17,11 @@ void dsp_putchar(int c)
                        dsp_write_data(inconsolata24[start + (i * 192 * 2) + j]);
        }
 
-       if (++curx == 26)
-               curx = 0, cury++;
+       if (++curx == 40) {
+               curx = 0;
+               if (++cury == 10)
+                       cury = 0;
+       }
 }
 
 void dsp_puts(const char *s)
@@ -27,3 +30,19 @@ void dsp_puts(const char *s)
        while (s[i])
                dsp_putchar(s[i++]);
 }
+
+void dsp_cpos(int x, int y)
+{
+       curx = x;
+       cury = y;
+}
+
+void dsp_rect(int x, int y, int w, int h, uint16_t color)
+{
+       dsp_set_addr(x, y, x + w - 1, y + h - 1);
+       int countdown = w * h;
+       do {
+               dsp_write_data(color >> 8);
+               dsp_write_data(color & 0xFF);
+       } while (countdown--);
+}
index b91a975ddfc41818ee1960f3b738d3362f1bbdd9..bab8f02812c69b9636329b55e7368e88f0f597a6 100644 (file)
@@ -5,6 +5,7 @@
 #include <gpio.h>\r
 #include <lcd.h>\r
 #include <display.h>\r
+#include <display_draw.h>\r
 #include <initrd.h>\r
 #include <serial.h>\r
 #include <parser.h>\r
@@ -43,8 +44,8 @@ int main(void)
 int script_puts(interpreter *it)\r
 {\r
        char *s = igetarg_string(it, 0);\r
-       //lcd_puts(s);\r
-       asm("mov r0, %0; svc 2" :: "r" (s));\r
+       dsp_puts(s);\r
+       //asm("mov r0, %0; svc 2" :: "r" (s));\r
        return 0;\r
 }\r
 \r
@@ -102,23 +103,17 @@ void kmain(void)
        asm("cpsie i");\r
 \r
        dsp_init();\r
-       //uint16_t c = 0x38;\r
-       uint16_t c = 0;\r
-       for (int i = 0; i < LCD_HEIGHT; i++) {\r
-               dsp_set_addr(0, i, LCD_WIDTH - 1, i);\r
-               int w = LCD_WIDTH - 1;\r
-               do {\r
-                       dsp_write_data(c);//c >> 8);\r
-                       dsp_write_data(c);//c & 0xFF);\r
-               } while (w--);\r
-       }\r
 \r
-       extern void dsp_puts(const char *);\r
-       dsp_puts("Hello, world! My name is Clyne.");\r
+       dsp_rect(0, 0, LCD_WIDTH, 105, dsp_color(0xFF, 0, 0));\r
+       dsp_rect(0, 105, LCD_WIDTH, 105, dsp_color(0, 0xFF, 0));\r
+       dsp_rect(0, 210, LCD_WIDTH, 110, dsp_color(0, 0, 0xFF));\r
+\r
+       //dsp_puts("Hello, world! My name is Clyne. I enjoy car rides and long \r
+//walks on the beach");\r
 \r
        //task_start(lcd_handler, 128);\r
        //delay(200);\r
-       //task_start(task_interpreter, 4096);\r
+       task_start(task_interpreter, 4096);\r
 \r
        //char *s = initrd_getfile("test.txt");\r
 \r