OSDN Git Service

Update lejos_osek to nxtOSEK_v205b0.zip
[nxt-jsp/etrobo-atk.git] / nxtOSEK / lejos_nxj / src / nxtvm / platform / nxt / nxt_lcd.c
index 6d7b99b..4f6ced2 100644 (file)
@@ -3,7 +3,7 @@
 #include "systick.h"
 #include "string.h"
 
-
+static U8 *display = (U8 *)0;
 
 void
 nxt_lcd_command(U8 cmd)
@@ -117,21 +117,34 @@ nxt_lcd_set_cursor_update(U32 on)
   nxt_lcd_command(0xEE | ((on) ? 1 : 0));
 }
 
-
 void
-nxt_lcd_data(const U8 *data)
+nxt_lcd_force_update()
 {
+  // Update the screen the slow way. Works with interrupts disabled
   int i;
+  U8 *disp = display;
 
   for (i = 0; i < NXT_LCD_DEPTH; i++) {
     nxt_lcd_set_col(0);
     nxt_lcd_set_page_address(i);
 
-    nxt_spi_write(1, data, NXT_LCD_WIDTH);
-    data += NXT_LCD_WIDTH;
+    nxt_spi_write(1, disp, NXT_LCD_WIDTH);
+    disp += NXT_LCD_WIDTH;
   }
 }
 
+
+void
+nxt_lcd_update()
+{
+#define DMA_REFRESH
+#ifdef DMA_REFRESH
+  nxt_spi_refresh();
+#else
+  nxt_lcd_force_update();
+#endif
+}
+
 void
 nxt_lcd_power_up(void)
 {
@@ -143,17 +156,24 @@ nxt_lcd_power_up(void)
   nxt_lcd_set_bias_ratio(3);   // 1/9
   nxt_lcd_set_pot(0x60);       // ?? 9V??
 
-  nxt_lcd_set_ram_address_control(0);
-  nxt_lcd_set_map_control(0x02);
+  nxt_lcd_set_ram_address_control(1); // auto wrap
+  nxt_lcd_set_map_control(0x02); // mirror in y
 
+  nxt_spi_set_display(display);
   nxt_lcd_enable(1);
 
 }
 
 void
-nxt_lcd_init(void)
+nxt_lcd_power_down(void)
 {
+       nxt_lcd_reset();
+}
 
+void
+nxt_lcd_init(const U8 *disp)
+{
+  display = disp;
   nxt_spi_init();
 
   nxt_lcd_power_up();