lib/unigraphic/SSD1322.cpp

changeset 6
8cb67d7afd79
parent 5
f1c85c2500f2
child 7
5cf4034ba4e0
--- a/lib/unigraphic/SSD1322.cpp	Tue Sep 20 23:50:45 2016 +0200
+++ b/lib/unigraphic/SSD1322.cpp	Wed Sep 21 20:09:21 2016 +0200
@@ -337,22 +337,24 @@
 
 
 
-// Set row address 0~32
-void SSD1322::set_row_address(unsigned char add)
+// Set row address 0~64
+void SSD1322::set_row_address(unsigned char start_row, unsigned char end_row)
 {
   wr_cmd8(SSD1322_CMD_SET_ROW_ADDR);
-  add &= 0x3F;
-  wr_data8(add);
-  wr_data8(0x3F);
+  start_row &= 0x3F;
+  wr_data8(start_row);
+  end_row &= 0x3F;
+  wr_data8(end_row);
 }
 
 // Set col address 0~64  for Gray mode)
-void SSD1322::set_column_address(unsigned char add)
+void SSD1322::set_column_address(unsigned char start_col, unsigned char end_col)
 {
   wr_cmd8(SSD1322_CMD_SET_COLUMN_ADDR);
-  add &= 0x3F;
-  wr_data8(0x1c+add); // where does this 0x1C (28) comes from???
-  wr_data8(0x5b); // this 0x5B (91) seems 28+64 (-1)
+  start_col = (start_col & 0x3F) + 0x1C;
+  wr_data8(start_col); // where does this 0x1C (28) comes from???
+  end_col = (end_col & 0x3F) + 0x1C;
+  wr_data8(end_col);
 }
 
 void SSD1322::copy_to_lcd(void)
@@ -370,6 +372,23 @@
       wr_data8(buffer[i++]);
 }
 
+void SSD1322::copy_to_lcd(unsigned char from_col, unsigned char to_col,
+			  unsigned char from_row, unsigned char to_row)
+{
+  unsigned char x, y;
+
+  set_row_address(from_row, to_row);
+  set_column_address(from_col, to_col);
+
+  wr_cmd8(SSD1322_CMD_WRITE_RAM);
+  for(y=from_row; y<=to_row; y++) {
+    for(x=from_col; x<=to_col; x++) { 
+      wr_data8(buffer[y*128 + 2*x]);
+      wr_data8(buffer[y*128 + 2*x + 1]);
+    }
+  }
+}
+
 unsigned long SSD1322::buffaddr(unsigned int i)
 {
   return (unsigned long) &(buffer[i]);

mercurial