Permalink
Browse files

New Universal Graphics Library

  • Loading branch information...
1 parent 7ef324f commit 2ed952c910d1e2ec769a0a7ae1b2b3ad14665a37 @msproul msproul committed Sep 4, 2011
Showing with 13,937 additions and 0 deletions.
  1. +354 −0 UnivGraphicsLib/GDt6963Stuff/GDt6963c.cpp
  2. BIN UnivGraphicsLib/GDt6963Stuff/T6963_Lib.zip
  3. +323 −0 UnivGraphicsLib/GDt6963Stuff/t6963c.c
  4. +124 −0 UnivGraphicsLib/GDt6963c.h
  5. +616 −0 UnivGraphicsLib/HX8347.h
  6. +1 −0 UnivGraphicsLib/HardwareDef.h
  7. +1 −0 UnivGraphicsLib/Hardware_GLCDt6963c.cxx
  8. +1 −0 UnivGraphicsLib/Hardware_GLCDt6963c.cxx.version1.cxx
  9. +401 −0 UnivGraphicsLib/Hardware_MikroElektronika.cxx
  10. +252 −0 UnivGraphicsLib/Hardware_MikroElektronika.h
  11. +595 −0 UnivGraphicsLib/Hardware_Nokia128.cxx
  12. +204 −0 UnivGraphicsLib/Hardware_Nokia128.h
  13. +1 −0 UnivGraphicsLib/Hardware_Picaso.cxx
  14. +389 −0 UnivGraphicsLib/Hardware_WideTFT copy.cxx
  15. +395 −0 UnivGraphicsLib/Hardware_WideTFT.cxx
  16. +488 −0 UnivGraphicsLib/Hardware_ks0108.cxx
  17. +223 −0 UnivGraphicsLib/HersheyAstrology.h
  18. +222 −0 UnivGraphicsLib/HersheyCursive.h
  19. +53 −0 UnivGraphicsLib/HersheyCyrillic.cpp
  20. +223 −0 UnivGraphicsLib/HersheyCyrillic.h
  21. +221 −0 UnivGraphicsLib/HersheyCyrillic1.h
  22. +1,275 −0 UnivGraphicsLib/HersheyFonts.cpp
  23. +283 −0 UnivGraphicsLib/HersheyFonts.h
  24. +227 −0 UnivGraphicsLib/HersheyFutural.h
  25. +230 −0 UnivGraphicsLib/HersheyFuturam.h
  26. +220 −0 UnivGraphicsLib/HersheyGothgbt.h
  27. +82 −0 UnivGraphicsLib/HersheyGothic.cpp
  28. +220 −0 UnivGraphicsLib/HersheyGothicEnglish.h
  29. +221 −0 UnivGraphicsLib/HersheyGothicGerman.h
  30. +224 −0 UnivGraphicsLib/HersheyGothicItalian.h
  31. +224 −0 UnivGraphicsLib/HersheyGothitt.h
  32. +59 −0 UnivGraphicsLib/HersheyGreek.cpp
  33. +223 −0 UnivGraphicsLib/HersheyGreek.h
  34. +221 −0 UnivGraphicsLib/HersheyGreekComplex.h
  35. +222 −0 UnivGraphicsLib/HersheyGreekSimplex.h
  36. +321 −0 UnivGraphicsLib/HersheyJapanese.h
  37. +222 −0 UnivGraphicsLib/HersheyMarkers.h
  38. +223 −0 UnivGraphicsLib/HersheyMathlow.h
  39. +222 −0 UnivGraphicsLib/HersheyMathupp.h
  40. +221 −0 UnivGraphicsLib/HersheyMeteorology.h
  41. +224 −0 UnivGraphicsLib/HersheyMusic.h
  42. +58 −0 UnivGraphicsLib/HersheyRowman.cpp
  43. +224 −0 UnivGraphicsLib/HersheyRowmanDuplex.h
  44. +1 −0 UnivGraphicsLib/HersheyRowmanSimplex.h
  45. +1 −0 UnivGraphicsLib/HersheyRowmanTriplex.h
  46. +49 −0 UnivGraphicsLib/HersheyScript.cpp
  47. +223 −0 UnivGraphicsLib/HersheyScriptComplex.h
  48. +222 −0 UnivGraphicsLib/HersheyScriptSimplex.h
  49. +221 −0 UnivGraphicsLib/HersheySymbolic.h
  50. +100 −0 UnivGraphicsLib/HersheySymbols.cpp
  51. +80 −0 UnivGraphicsLib/HersheyTimes.cpp
  52. +220 −0 UnivGraphicsLib/HersheyTimesGreek.h
  53. +221 −0 UnivGraphicsLib/HersheyTimesItalic.h
  54. +221 −0 UnivGraphicsLib/HersheyTimesItalicBold.h
  55. +221 −0 UnivGraphicsLib/HersheyTimesRoman.h
  56. +221 −0 UnivGraphicsLib/HersheyTimesRomanBold.h
  57. +1 −0 UnivGraphicsLib/NewHavenPic.h
  58. +153 −0 UnivGraphicsLib/SystemFont5x7.h
  59. +1 −0 UnivGraphicsLib/UnivGraphicsHW_Defs.h
  60. +1 −0 UnivGraphicsLib/UnivGraphicsHardware.h
  61. +1 −0 UnivGraphicsLib/UnivGraphicsLib.cpp
  62. +1 −0 UnivGraphicsLib/UnivGraphicsLib.h
  63. +629 −0 UnivGraphicsLib/drvTFT002.h
  64. +1 −0 UnivGraphicsLib/examples/UnivGraphicsDemo/UnivGraphicsDemo.pde
  65. +1 −0 UnivGraphicsLib/examples/UnivGraphicsDemo/ugl_config.h
  66. 0 UnivGraphicsLib/font.h
  67. +194 −0 UnivGraphicsLib/ks0108.h
  68. +66 −0 UnivGraphicsLib/ks0108_Arduino.h
  69. +51 −0 UnivGraphicsLib/ks0108_Mega.h
  70. +42 −0 UnivGraphicsLib/ks0108_Panel.h
  71. +59 −0 UnivGraphicsLib/ks0108_Sanguino.h
  72. +1 −0 UnivGraphicsLib/rotatingballs.c
  73. +1 −0 UnivGraphicsLib/rotatingballs.h
@@ -0,0 +1,354 @@
+//-------------------------------------------------------------------------------------------------
+// Graphic LCD with Toshiba T6963 controller
+// Copyright (c) Radoslaw Kwiecien, 2007r
+// http://en.radzio.dxp.pl/t6963/
+// Compiler : avr-gcc
+// Modified By -Gil- to work on Arduino easily : http://domoduino.tumblr.com/
+//-------------------------------------------------------------------------------------------------
+#include "GDT6963C.h"
+//-------------------------------------------------------------------------------------------------
+//
+// Delay function
+//
+//-------------------------------------------------------------------------------------------------
+void n_delay(void)
+{
+volatile unsigned char i;
+
+ for(i = 0; i < (F_CPU/1000000); i++)
+ {
+ asm("nop");
+ }
+}
+//-------------------------------------------------------------------------------------------------
+//
+// Ports intalization
+//
+//-------------------------------------------------------------------------------------------------
+void GLCD_InitalizeInterface(void)
+{
+ //GLCD_DATA_DDR = 0xFF;
+ GLCD_DATA_DDR1 |= GLCD_DATA_MASK1;
+ GLCD_DATA_DDR2 |= GLCD_DATA_MASK2;
+
+ GLCD_CTRL_DDR = ((1 << GLCD_WR) | (1 << GLCD_RD) | (1 << GLCD_CE) | (1 << GLCD_CD) | (1 << GLCD_RESET) | (1 << GLCD_FS));
+ GLCD_CTRL_PORT |= ((1 << GLCD_WR) | (1 << GLCD_RD) | (1 << GLCD_CE) | (1 << GLCD_CD) | (1 << GLCD_RESET) | (1 << GLCD_FS));
+}
+//-------------------------------------------------------------------------------------------------
+//
+// Reads dispay status
+//
+//-------------------------------------------------------------------------------------------------
+unsigned char GLCD_ChceckStatus(void)
+{
+ uint8_t tmp;
+ //GLCD_DATA_DDR = 0x00;
+ GLCD_DATA_DDR1 &= ~GLCD_DATA_MASK1;
+ GLCD_DATA_DDR2 &= ~GLCD_DATA_MASK2;
+
+ GLCD_CTRL_PORT &= ~((1 << GLCD_RD) | (1 << GLCD_CE));
+ n_delay();
+ //tmp = GLCD_DATA_PIN;
+ tmp = (GLCD_DATA_PIN1 GLCD_DATA_RSHIFT1) | (GLCD_DATA_PIN2 GLCD_DATA_RSHIFT2);
+ //GLCD_DATA_DDR = 0xFF;
+ GLCD_DATA_DDR1 |= GLCD_DATA_MASK1;
+ GLCD_DATA_DDR2 |= GLCD_DATA_MASK2;
+ GLCD_CTRL_PORT |= ((1 << GLCD_RD) | (1 << GLCD_CE));
+ return tmp;
+}
+//-------------------------------------------------------------------------------------------------
+//
+// Writes instruction
+//
+//-------------------------------------------------------------------------------------------------
+void GLCD_WriteCommand(unsigned char command)
+{
+ while(!(GLCD_ChceckStatus()&0x03));
+
+ // GLCD_DATA_PORT = command;
+ GLCD_DATA_PORT1 &= ~GLCD_DATA_MASK1;
+ GLCD_DATA_PORT1 |= (command GLCD_DATA_SHIFT1);
+ GLCD_DATA_PORT2 &= ~GLCD_DATA_MASK2;
+ GLCD_DATA_PORT2 |= (command GLCD_DATA_SHIFT2);
+
+
+ GLCD_CTRL_PORT &= ~((1 << GLCD_WR) | (1 << GLCD_CE));
+ n_delay();
+ GLCD_CTRL_PORT |= ((1 << GLCD_WR) | (1 << GLCD_CE));
+}
+
+//-------------------------------------------------------------------------------------------------
+//
+// Writes data
+//
+//-------------------------------------------------------------------------------------------------
+void GLCD_WriteData(unsigned char data)
+{
+ while(!(GLCD_ChceckStatus()&0x03));
+ // GLCD_DATA_PORT = data;
+ GLCD_DATA_PORT1 &= ~GLCD_DATA_MASK1;
+ GLCD_DATA_PORT1 |= (data GLCD_DATA_SHIFT1);
+ GLCD_DATA_PORT2 &= ~GLCD_DATA_MASK2;
+ GLCD_DATA_PORT2 |= (data GLCD_DATA_SHIFT2);
+
+ GLCD_CTRL_PORT &= ~((1 << GLCD_WR) | (1 << GLCD_CE) | (1 << GLCD_CD));
+ n_delay();
+ GLCD_CTRL_PORT |= ((1 << GLCD_WR) | (1 << GLCD_CE) | (1 << GLCD_CD));
+}
+//-------------------------------------------------------------------------------------------------
+//
+// Reads data
+//
+//-------------------------------------------------------------------------------------------------
+unsigned char GLCD_ReadData(void)
+{
+ uint8_t tmp;
+ while(!(GLCD_ChceckStatus()&0x03));
+ //GLCD_DATA_DDR = 0x00;
+ GLCD_DATA_DDR1 &= ~GLCD_DATA_MASK1;
+ GLCD_DATA_DDR2 &= ~GLCD_DATA_MASK2;
+
+ GLCD_CTRL_PORT &= ~((1 << GLCD_RD) | (1 << GLCD_CE) | (1 << GLCD_CD));
+ n_delay();
+
+ //tmp = GLCD_DATA_PIN;
+ tmp = (GLCD_DATA_PIN1 GLCD_DATA_RSHIFT1) | (GLCD_DATA_PIN2 GLCD_DATA_RSHIFT2);
+ GLCD_CTRL_PORT |= ((1 << GLCD_RD) | (1 << GLCD_CE) | (1 << GLCD_CD));
+ //GLCD_DATA_DDR = 0xFF;
+ GLCD_DATA_DDR1 |= GLCD_DATA_MASK1;
+ GLCD_DATA_DDR2 |= GLCD_DATA_MASK2;
+
+ return tmp;
+}
+//-------------------------------------------------------------------------------------------------
+//
+// Sets address pointer for display RAM memory
+//
+//-------------------------------------------------------------------------------------------------
+void GLCD_SetAddressPointer(unsigned int address)
+{
+ GLCD_WriteData(address & 0xFF);
+ GLCD_WriteData(address >> 8);
+ GLCD_WriteCommand(T6963_SET_ADDRESS_POINTER);
+}
+//-------------------------------------------------------------------------------------------------
+//
+// Clears text area of display RAM memory
+//
+//-------------------------------------------------------------------------------------------------
+void GLCD_ClearText(void)
+{
+int i;
+ GLCD_SetAddressPointer(GLCD_TEXT_HOME);
+
+ for(i = 0; i < GLCD_TEXT_SIZE; i++)
+ {
+ GLCD_WriteDisplayData(0);
+ }
+}
+//-------------------------------------------------------------------------------------------------
+//
+// Clears characters generator area of display RAM memory
+//
+//-------------------------------------------------------------------------------------------------
+void GLCD_ClearCG(void)
+{
+unsigned int i;
+ GLCD_SetAddressPointer(GLCD_EXTERNAL_CG_HOME);
+
+ for(i = 0; i < 256 * 8; i++)
+ {
+ GLCD_WriteDisplayData(0);
+ }
+}
+//-------------------------------------------------------------------------------------------------
+//
+// Clears graphics area of display RAM memory
+//
+//-------------------------------------------------------------------------------------------------
+void GLCD_ClearGraphic(void)
+{
+int i;
+ GLCD_SetAddressPointer(GLCD_GRAPHIC_HOME);
+ for(i = 0; i < GLCD_GRAPHIC_SIZE; i++)
+ {
+ GLCD_WriteDisplayData(0x00);
+ }
+}
+//-------------------------------------------------------------------------------------------------
+//
+// Writes a single character (ASCII code) to display RAM memory
+//
+//-------------------------------------------------------------------------------------------------
+void GLCD_WriteChar(char charCode)
+{
+ GLCD_WriteDisplayData(charCode - 32);
+}
+//-------------------------------------------------------------------------------------------------
+//
+// Writes null-terminated string to display RAM memory
+//
+//-------------------------------------------------------------------------------------------------
+void GLCD_WriteString(char * string)
+{
+ while(*string)
+ {
+ GLCD_WriteChar(*string++);
+ }
+}
+//-------------------------------------------------------------------------------------------------
+//
+// Writes null-terminated string from program memory to display RAM memory
+//
+//-------------------------------------------------------------------------------------------------
+void GLCD_WriteStringPgm(prog_char * string)
+{
+char ch;
+ while((ch = pgm_read_byte(string++)))
+ {
+ GLCD_WriteChar(ch);
+ }
+}
+//-------------------------------------------------------------------------------------------------
+//
+// Sets display coordinates
+//
+//-------------------------------------------------------------------------------------------------
+void GLCD_TextGoTo(unsigned char x, unsigned char y)
+{
+unsigned int address;
+
+ address = GLCD_TEXT_HOME + x + (GLCD_TEXT_AREA * y);
+
+ GLCD_SetAddressPointer(address);
+}
+//-------------------------------------------------------------------------------------------------
+//
+// Writes single char pattern to character generator area of display RAM memory
+//
+//-------------------------------------------------------------------------------------------------
+void GLCD_DefineCharacter(unsigned char charCode, unsigned char * defChar)
+{
+unsigned int address;
+unsigned char i;
+
+ address = GLCD_EXTERNAL_CG_HOME + (8 * charCode);
+
+ GLCD_SetAddressPointer(address);
+
+ for(i = 0; i < 8 ; i++)
+ {
+ GLCD_WriteDisplayData(*(defChar + i));
+ }
+}
+
+//-------------------------------------------------------------------------------------------------
+//
+// Set (if color==1) or clear (if color==0) pixel on screen
+//
+//-------------------------------------------------------------------------------------------------
+void GLCD_SetPixel(unsigned char x, unsigned char y, unsigned char color)
+{
+unsigned char tmp;
+unsigned int address;
+
+ address = GLCD_GRAPHIC_HOME + (x / GLCD_FONT_WIDTH) + (GLCD_GRAPHIC_AREA * y);
+
+ GLCD_SetAddressPointer(address);
+
+ GLCD_WriteCommand(T6963_DATA_READ_AND_NONVARIABLE);
+ tmp = GLCD_ReadData();
+
+ if(color)
+ {
+ tmp |= (1 << (GLCD_FONT_WIDTH - 1 - (x % GLCD_FONT_WIDTH)));
+ }
+ else
+ {
+ tmp &= ~(1 << (GLCD_FONT_WIDTH - 1 - (x % GLCD_FONT_WIDTH)));
+ }
+ GLCD_WriteDisplayData(tmp);
+
+}
+//-------------------------------------------------------------------------------------------------
+//
+// Writes display data and increment address pointer
+//
+//-------------------------------------------------------------------------------------------------
+void GLCD_WriteDisplayData(unsigned char x)
+{
+ GLCD_WriteData(x);
+ GLCD_WriteCommand(T6963_DATA_WRITE_AND_INCREMENT);
+}
+//-------------------------------------------------------------------------------------------------
+//
+// Sets graphics coordinates
+//
+//-------------------------------------------------------------------------------------------------
+void GLCD_GraphicGoTo(unsigned char x, unsigned char y)
+{
+unsigned int address;
+ address = GLCD_GRAPHIC_HOME + (x / GLCD_FONT_WIDTH) + (GLCD_GRAPHIC_AREA * y);
+ GLCD_SetAddressPointer(address);
+}
+//-------------------------------------------------------------------------------------------------
+//
+// Displays bitmap from program memory
+//
+//-------------------------------------------------------------------------------------------------
+void GLCD_Bitmap(unsigned char * bitmap, unsigned char x, unsigned char y, unsigned char width, unsigned char height)
+{
+unsigned char i, j;
+
+ for(j = 0; j < height; j++)
+ {
+ GLCD_GraphicGoTo(x, y + j);
+ for(i = 0; i < width/GLCD_FONT_WIDTH; i++)
+ {
+ GLCD_WriteDisplayData(pgm_read_byte(bitmap + i + (GLCD_GRAPHIC_AREA * j)));
+ }
+ }
+}
+//-------------------------------------------------------------------------------------------------
+//
+// Display initalization
+//
+//-------------------------------------------------------------------------------------------------
+void GLCD_Initalize(void)
+{
+
+ GLCD_InitalizeInterface();
+
+ GLCD_CTRL_PORT &= ~(1 << GLCD_RESET);
+ _delay_ms(1);
+ GLCD_CTRL_PORT |= (1 << GLCD_RESET);
+
+ #if (GLCD_FONT_WIDTH == 8)
+ GLCD_CTRL_PORT &= ~(1 << GLCD_FS);
+ #endif
+
+ GLCD_WriteData(GLCD_GRAPHIC_HOME & 0xFF);
+ GLCD_WriteData(GLCD_GRAPHIC_HOME >> 8);
+ GLCD_WriteCommand(T6963_SET_GRAPHIC_HOME_ADDRESS);
+
+ GLCD_WriteData(GLCD_GRAPHIC_AREA);
+ GLCD_WriteData(0x00);
+ GLCD_WriteCommand(T6963_SET_GRAPHIC_AREA);
+
+ GLCD_WriteData(GLCD_TEXT_HOME);
+ GLCD_WriteData(GLCD_TEXT_HOME >> 8);
+ GLCD_WriteCommand(T6963_SET_TEXT_HOME_ADDRESS);
+
+ GLCD_WriteData(GLCD_TEXT_AREA);
+ GLCD_WriteData(0x00);
+ GLCD_WriteCommand(T6963_SET_TEXT_AREA);
+
+ GLCD_WriteData(GLCD_OFFSET_REGISTER);
+ GLCD_WriteData(0x00);
+ GLCD_WriteCommand(T6963_SET_OFFSET_REGISTER);
+
+ GLCD_WriteCommand(T6963_DISPLAY_MODE | T6963_GRAPHIC_DISPLAY_ON | T6963_TEXT_DISPLAY_ON /*| T6963_CURSOR_DISPLAY_ON*/);
+
+ GLCD_WriteCommand(T6963_MODE_SET | 0);
+
+}
Binary file not shown.
Oops, something went wrong.

0 comments on commit 2ed952c

Please sign in to comment.