Latest version with SSD1963 Graphics Driver

Dependencies:   mbed

Committer:
andrewcrussell
Date:
Mon Apr 04 05:32:25 2011 +0000
Revision:
1:ecf8078bf531
Child:
2:67e16df2c89a

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
andrewcrussell 1:ecf8078bf531 1 /***********************************************************************************/
andrewcrussell 1:ecf8078bf531 2 /***** Newhaven NHD-5.7-640480WF-CTXL# Display Driver **********/
andrewcrussell 1:ecf8078bf531 3 /***** for mbed (www.mbed,org) NXP LPC1768 32 bit ARM MCU ******/
andrewcrussell 1:ecf8078bf531 4 /********* Adapted by Andrew C. Russell, March 2011 ***********/
andrewcrussell 1:ecf8078bf531 5
andrewcrussell 1:ecf8078bf531 6 /************I hereby acknowledge and thank the following ******/
andrewcrussell 1:ecf8078bf531 7 /***software authors whose code I have adapted and/or adopted***/
andrewcrussell 1:ecf8078bf531 8 /*******************to create these drivers:- ******************/
andrewcrussell 1:ecf8078bf531 9
andrewcrussell 1:ecf8078bf531 10 //Curt Lagerstam - Newhaven Display International, LLC for the dispay initialization.
andrewcrussell 1:ecf8078bf531 11 //James P Lynch - code adapted from his Nokia LCD display tutorial at
andrewcrussell 1:ecf8078bf531 12 //http://www.sparkfun.com/tutorial/Nokia%206100%20LCD%20Display%20Driver.pdf
andrewcrussell 1:ecf8078bf531 13 //Akifumi 'Tedd' Okano for assistance and adapting the .bmp display driver and writing
andrewcrussell 1:ecf8078bf531 14 //the driver for the font display
andrewcrussell 1:ecf8078bf531 15 /***********************************************************************************/
andrewcrussell 1:ecf8078bf531 16
andrewcrussell 1:ecf8078bf531 17 //#include "mbed.h"
andrewcrussell 1:ecf8078bf531 18 //#include "font_1.h"
andrewcrussell 1:ecf8078bf531 19 //#include "stdlib.h"
andrewcrussell 1:ecf8078bf531 20 //#include "string.h"
andrewcrussell 1:ecf8078bf531 21 //#include "math.h"
andrewcrussell 1:ecf8078bf531 22 #include "font_new.h"
andrewcrussell 1:ecf8078bf531 23 //#include "system_defines.h"
andrewcrussell 1:ecf8078bf531 24
andrewcrussell 1:ecf8078bf531 25 /***********************************************************************************/
andrewcrussell 1:ecf8078bf531 26 /********************************** Colors *****************************************/
andrewcrussell 1:ecf8078bf531 27 /********* taken directly from http://web.njit.edu/~kevin/rgb.txt.html**************/
andrewcrussell 1:ecf8078bf531 28 #define BLACK 0x000000
andrewcrussell 1:ecf8078bf531 29 #define WHITE 0xFFFFFF
andrewcrussell 1:ecf8078bf531 30 #define BLACK 0x000000
andrewcrussell 1:ecf8078bf531 31 #define RED 0xFF0000
andrewcrussell 1:ecf8078bf531 32 #define GREEN 0x00FF00
andrewcrussell 1:ecf8078bf531 33 #define LGREEN 0xCCFF00 //light green
andrewcrussell 1:ecf8078bf531 34 #define BLUE 0x0000FF
andrewcrussell 1:ecf8078bf531 35 #define GREY 0xBEBEBE
andrewcrussell 1:ecf8078bf531 36 #define DEEPINK 0xFF1493
andrewcrussell 1:ecf8078bf531 37 #define YELLOW 0xFFFF00
andrewcrussell 1:ecf8078bf531 38 #define LORANGE 0xFFFF00 //light orange
andrewcrussell 1:ecf8078bf531 39 #define DORANGE 0xFF9900 //dark orange
andrewcrussell 1:ecf8078bf531 40 #define OLIVE 0x999900
andrewcrussell 1:ecf8078bf531 41
andrewcrussell 1:ecf8078bf531 42 #define PASET 0x2B
andrewcrussell 1:ecf8078bf531 43 #define CASET 0x2A
andrewcrussell 1:ecf8078bf531 44 #define DISON 0x29
andrewcrussell 1:ecf8078bf531 45 #define DISOFF 0x28
andrewcrussell 1:ecf8078bf531 46 #define DEEPSLEEP 0xE5
andrewcrussell 1:ecf8078bf531 47 #define RAMWR 0x2C
andrewcrussell 1:ecf8078bf531 48 #define RAMCT 0x3C
andrewcrussell 1:ecf8078bf531 49 #define RESET 0x01
andrewcrussell 1:ecf8078bf531 50 #define DISINV 0x21
andrewcrussell 1:ecf8078bf531 51 #define DISNOR 0x20
andrewcrussell 1:ecf8078bf531 52 #define NOP 0x00
andrewcrussell 1:ecf8078bf531 53 #define XMAX 640
andrewcrussell 1:ecf8078bf531 54 #define YMAX 480
andrewcrussell 1:ecf8078bf531 55 #define TRUE 1
andrewcrussell 1:ecf8078bf531 56 #define SPAN 460
andrewcrussell 1:ecf8078bf531 57 #define ZERO 100
andrewcrussell 1:ecf8078bf531 58 #define PI 3.14159265
andrewcrussell 1:ecf8078bf531 59
andrewcrussell 1:ecf8078bf531 60 // Font sizes
andrewcrussell 1:ecf8078bf531 61 #define SMALL 0
andrewcrussell 1:ecf8078bf531 62 #define MEDIUM 1
andrewcrussell 1:ecf8078bf531 63 #define LARGE 2
andrewcrussell 1:ecf8078bf531 64 #define LARGE1 3
andrewcrussell 1:ecf8078bf531 65 /********************************************************************/
andrewcrussell 1:ecf8078bf531 66 #ifdef TEST
andrewcrussell 1:ecf8078bf531 67 extern unsigned char screen[ SC_WIDTH * SC_HEIGHT ] = { '.' };
andrewcrussell 1:ecf8078bf531 68 #endif
andrewcrussell 1:ecf8078bf531 69 /********************************************************************/
andrewcrussell 1:ecf8078bf531 70 //unsigned char FONT6x8[97][8];
andrewcrussell 1:ecf8078bf531 71 //unsigned char FONT8x8[97][8];
andrewcrussell 1:ecf8078bf531 72 //unsigned char FONT8x16[97][8];
andrewcrussell 1:ecf8078bf531 73 /************ here the XY reference locations for the buttons ************/
andrewcrussell 1:ecf8078bf531 74 int righttbutinc=76;
andrewcrussell 1:ecf8078bf531 75 int xref2=590; //right hand side button x reference
andrewcrussell 1:ecf8078bf531 76 int xref1=16; //left hand side button x reference
andrewcrussell 1:ecf8078bf531 77 int leftbutinc=76; //y axis increment for the left hand side buttons
andrewcrussell 1:ecf8078bf531 78 int yref1=70;
andrewcrussell 1:ecf8078bf531 79 int xbutsize1=60; // x size of button
andrewcrussell 1:ecf8078bf531 80 int ybutsize1=50; // y size of button
andrewcrussell 1:ecf8078bf531 81 /************************************************************************/
andrewcrussell 1:ecf8078bf531 82 unsigned char command;
andrewcrussell 1:ecf8078bf531 83 unsigned char data1;
andrewcrussell 1:ecf8078bf531 84 int DOWN;
andrewcrussell 1:ecf8078bf531 85 int RIGHT;
andrewcrussell 1:ecf8078bf531 86 int color;
andrewcrussell 1:ecf8078bf531 87 unsigned int fill;
andrewcrussell 1:ecf8078bf531 88 unsigned int radius;
andrewcrussell 1:ecf8078bf531 89 int z;
andrewcrussell 1:ecf8078bf531 90 //float slider;
andrewcrussell 1:ecf8078bf531 91 //float vol;
andrewcrussell 1:ecf8078bf531 92
andrewcrussell 1:ecf8078bf531 93 /**************************** forward references *******************************/
andrewcrussell 1:ecf8078bf531 94 void LCDSetXY(int x, int y);
andrewcrussell 1:ecf8078bf531 95 void LCDClearScreen(void);
andrewcrussell 1:ecf8078bf531 96 void LCDSetPixel(int x, int y, int color);
andrewcrussell 1:ecf8078bf531 97 void LCDSetLine(int x1, int y1, int x2, int y2, int color);
andrewcrussell 1:ecf8078bf531 98 void LCDSetRect(int x0, int y0, int x1, int y1, int fill, int color);
andrewcrussell 1:ecf8078bf531 99 void LCDSetCircle(int x0, int y0, int radius, int color);
andrewcrussell 1:ecf8078bf531 100 void LCDPutChar(char c, int x, int y, int size, int fcolor, int bcolor);
andrewcrussell 1:ecf8078bf531 101 void LCDPutString (char *lcd_string, const char *font_style, unsigned char x, unsigned char y,
andrewcrussell 1:ecf8078bf531 102 unsigned char fcolor, unsigned char bcolor);
andrewcrussell 1:ecf8078bf531 103 void trigcircle (int xtc, int ytc, int radius, int color);
andrewcrussell 1:ecf8078bf531 104 void show_screen( int xs, int width, int ys, int height );
andrewcrussell 1:ecf8078bf531 105 void volume_slider (int volume);
andrewcrussell 1:ecf8078bf531 106 //************************************************************************************
andrewcrussell 1:ecf8078bf531 107
andrewcrussell 1:ecf8078bf531 108 void Write_Command(unsigned char command) {
andrewcrussell 1:ecf8078bf531 109 CS=1; /* just to make sure */
andrewcrussell 1:ecf8078bf531 110 nRD = 1; /* make sure the RD is HIGH just to be sure */
andrewcrussell 1:ecf8078bf531 111 DC=0;
andrewcrussell 1:ecf8078bf531 112 nWR = 0;
andrewcrussell 1:ecf8078bf531 113 CS=0;
andrewcrussell 1:ecf8078bf531 114 //data_bus_write(command);
andrewcrussell 1:ecf8078bf531 115 DB=command;
andrewcrussell 1:ecf8078bf531 116 CS = 1;
andrewcrussell 1:ecf8078bf531 117 nWR = 1;
andrewcrussell 1:ecf8078bf531 118 }
andrewcrussell 1:ecf8078bf531 119 //;******************************************************************************
andrewcrussell 1:ecf8078bf531 120 //void Write_Data(unsigned char data1) {
andrewcrussell 1:ecf8078bf531 121 void Write_Data(int data1) {
andrewcrussell 1:ecf8078bf531 122 CS=1; /* just to make sure */
andrewcrussell 1:ecf8078bf531 123 nRD = 1;
andrewcrussell 1:ecf8078bf531 124 DC=1;
andrewcrussell 1:ecf8078bf531 125 nWR = 0;
andrewcrussell 1:ecf8078bf531 126 CS=0;
andrewcrussell 1:ecf8078bf531 127 //data_bus_write(data1);
andrewcrussell 1:ecf8078bf531 128 DB=data1;//write(data1);
andrewcrussell 1:ecf8078bf531 129 CS = 1;
andrewcrussell 1:ecf8078bf531 130 nWR = 1;
andrewcrussell 1:ecf8078bf531 131 }
andrewcrussell 1:ecf8078bf531 132 //====================================================
andrewcrussell 1:ecf8078bf531 133 void Command_Write(unsigned char REG,unsigned char VALUE) {
andrewcrussell 1:ecf8078bf531 134 Write_Command(REG);
andrewcrussell 1:ecf8078bf531 135 Write_Data(VALUE);
andrewcrussell 1:ecf8078bf531 136 }
andrewcrussell 1:ecf8078bf531 137 //======================================================
andrewcrussell 1:ecf8078bf531 138 void SendData(unsigned long color) {
andrewcrussell 1:ecf8078bf531 139 Write_Data((color)>>16); //red
andrewcrussell 1:ecf8078bf531 140 Write_Data((color)>>8); //green
andrewcrussell 1:ecf8078bf531 141 Write_Data(color); //blue
andrewcrussell 1:ecf8078bf531 142 }
andrewcrussell 1:ecf8078bf531 143 /********************************************************************************/
andrewcrussell 1:ecf8078bf531 144 // initialize the SSD1963 controller
andrewcrussell 1:ecf8078bf531 145 void Init_SSD1963 (void) {
andrewcrussell 1:ecf8078bf531 146 Write_Command(0x01); //Software Reset
andrewcrussell 1:ecf8078bf531 147 wait_ms(10);
andrewcrussell 1:ecf8078bf531 148 Write_Command(0x01); //Software Reset
andrewcrussell 1:ecf8078bf531 149 wait_ms(10);
andrewcrussell 1:ecf8078bf531 150 Write_Command(0x01); //Software Reset
andrewcrussell 1:ecf8078bf531 151 wait_ms(10);
andrewcrussell 1:ecf8078bf531 152 Command_Write(0xe0,0x01); //START PLL
andrewcrussell 1:ecf8078bf531 153 wait_us(1);
andrewcrussell 1:ecf8078bf531 154 Command_Write(0xe0,0x03); //LOCK PLL
andrewcrussell 1:ecf8078bf531 155 Write_Command(0xb0); //SET LCD MODE SET TFT 18Bits MODE
andrewcrussell 1:ecf8078bf531 156 Write_Data(0x0c); //SET TFT MODE & hsync+Vsync+DEN MODE
andrewcrussell 1:ecf8078bf531 157 Write_Data(0x80); //SET TFT MODE & hsync+Vsync+DEN MODE
andrewcrussell 1:ecf8078bf531 158 Write_Data(0x02); //SET horizontal size=640-1 HightByte
andrewcrussell 1:ecf8078bf531 159 Write_Data(0x7f); //SET horizontal size=640-1 LowByte
andrewcrussell 1:ecf8078bf531 160 Write_Data(0x01); //SET vertical size=480-1 HightByte
andrewcrussell 1:ecf8078bf531 161 Write_Data(0xdf); //SET vertical size=480-1 LowByte
andrewcrussell 1:ecf8078bf531 162 Write_Data(0x00); //SET even/odd line RGB seq.=RGB
andrewcrussell 1:ecf8078bf531 163 Command_Write(0xf0,0x00); //SET pixel data I/F format=8bit
andrewcrussell 1:ecf8078bf531 164 Command_Write(0x3a,0x60); // SET R G B format = 6 6 6
andrewcrussell 1:ecf8078bf531 165 Write_Command(0xe6); //SET PCLK freq=4.94MHz ; pixel clock frequency
andrewcrussell 1:ecf8078bf531 166 Write_Data(0x02);
andrewcrussell 1:ecf8078bf531 167 Write_Data(0xff);
andrewcrussell 1:ecf8078bf531 168 Write_Data(0xff);
andrewcrussell 1:ecf8078bf531 169 Write_Command(0xb4); //SET HBP,
andrewcrussell 1:ecf8078bf531 170 Write_Data(0x02); //SET HSYNC Total=760
andrewcrussell 1:ecf8078bf531 171 Write_Data(0xf8);
andrewcrussell 1:ecf8078bf531 172 Write_Data(0x00); //SET HBP 68
andrewcrussell 1:ecf8078bf531 173 Write_Data(0x44);
andrewcrussell 1:ecf8078bf531 174 Write_Data(0x0f); //SET VBP 16=15+1
andrewcrussell 1:ecf8078bf531 175 Write_Data(0x00); //SET Hsync pulse start position
andrewcrussell 1:ecf8078bf531 176 Write_Data(0x00);
andrewcrussell 1:ecf8078bf531 177 Write_Data(0x00); //SET Hsync pulse subpixel start position
andrewcrussell 1:ecf8078bf531 178 Write_Command(0xb6); //SET VBP,
andrewcrussell 1:ecf8078bf531 179 Write_Data(0x01); //SET Vsync total
andrewcrussell 1:ecf8078bf531 180 Write_Data(0xf8);
andrewcrussell 1:ecf8078bf531 181 Write_Data(0x00); //SET VBP=19
andrewcrussell 1:ecf8078bf531 182 Write_Data(0x13);
andrewcrussell 1:ecf8078bf531 183 Write_Data(0x07); //SET Vsync pulse 8=7+1
andrewcrussell 1:ecf8078bf531 184 Write_Data(0x00); //SET Vsync pulse start position
andrewcrussell 1:ecf8078bf531 185 Write_Data(0x00);
andrewcrussell 1:ecf8078bf531 186 Write_Command(0x2a); //SET column address
andrewcrussell 1:ecf8078bf531 187 Write_Data(0x00); //SET start column address=0
andrewcrussell 1:ecf8078bf531 188 Write_Data(0x00);
andrewcrussell 1:ecf8078bf531 189 Write_Data(0x02); //SET end column address=639
andrewcrussell 1:ecf8078bf531 190 Write_Data(0x7f);
andrewcrussell 1:ecf8078bf531 191 Write_Command(0x2b); //SET page address
andrewcrussell 1:ecf8078bf531 192 Write_Data(0x00); //SET start page address=0
andrewcrussell 1:ecf8078bf531 193 Write_Data(0x00);
andrewcrussell 1:ecf8078bf531 194 Write_Data(0x01); //SET end page address=479
andrewcrussell 1:ecf8078bf531 195 Write_Data(0xdf);
andrewcrussell 1:ecf8078bf531 196 Write_Command(0x29); //SET display on
andrewcrussell 1:ecf8078bf531 197 }
andrewcrussell 1:ecf8078bf531 198
andrewcrussell 1:ecf8078bf531 199
andrewcrussell 1:ecf8078bf531 200 /********************************************************************************/
andrewcrussell 1:ecf8078bf531 201 void WindowSet( int s_x,int e_x,int s_y,int e_y) {
andrewcrussell 1:ecf8078bf531 202 Write_Command(CASET); //SET page address
andrewcrussell 1:ecf8078bf531 203 Write_Data((s_x)>>8); //SET start page address=0
andrewcrussell 1:ecf8078bf531 204 Write_Data(s_x);
andrewcrussell 1:ecf8078bf531 205 Write_Data((e_x)>>8); //SET end page address=639
andrewcrussell 1:ecf8078bf531 206 Write_Data(e_x);
andrewcrussell 1:ecf8078bf531 207 Write_Command(PASET); //SET column address
andrewcrussell 1:ecf8078bf531 208 Write_Data((s_y)>>8); //SET start column address=0
andrewcrussell 1:ecf8078bf531 209 Write_Data(s_y);
andrewcrussell 1:ecf8078bf531 210 Write_Data((e_y)>>8); //SET end column address=479
andrewcrussell 1:ecf8078bf531 211 Write_Data(e_y);
andrewcrussell 1:ecf8078bf531 212 }
andrewcrussell 1:ecf8078bf531 213 /***************************************************************************/
andrewcrussell 1:ecf8078bf531 214 /* this routine locates the screen pointer at position XY in the frame buffer */
andrewcrussell 1:ecf8078bf531 215 void LCDSetXY(int x, int y) {
andrewcrussell 1:ecf8078bf531 216 Write_Command(CASET); //SET page address
andrewcrussell 1:ecf8078bf531 217 Write_Data((x)>>8); //SET start page address=0
andrewcrussell 1:ecf8078bf531 218 Write_Data(x);
andrewcrussell 1:ecf8078bf531 219 Write_Data((XMAX)>>8); //SET end page address=XMAX
andrewcrussell 1:ecf8078bf531 220 Write_Data(XMAX);
andrewcrussell 1:ecf8078bf531 221 Write_Command(PASET); //SET column address
andrewcrussell 1:ecf8078bf531 222 Write_Data((y)>>8); //SET start column address=0
andrewcrussell 1:ecf8078bf531 223 Write_Data(y);
andrewcrussell 1:ecf8078bf531 224 Write_Data((YMAX)>>8); //SET end column address=YMAX
andrewcrussell 1:ecf8078bf531 225 Write_Data(YMAX);
andrewcrussell 1:ecf8078bf531 226 Write_Command(RAMWR); //ready to now start writing the data
andrewcrussell 1:ecf8078bf531 227 //when returnung to the caller
andrewcrussell 1:ecf8078bf531 228 }
andrewcrussell 1:ecf8078bf531 229
andrewcrussell 1:ecf8078bf531 230
andrewcrussell 1:ecf8078bf531 231 /********************************************************************************/
andrewcrussell 1:ecf8078bf531 232 void clear_to_color(int color) {
andrewcrussell 1:ecf8078bf531 233 int m,n;
andrewcrussell 1:ecf8078bf531 234 WindowSet(0,640,0,480); // 0-640 wide by 0-480 high
andrewcrussell 1:ecf8078bf531 235 Write_Command(RAMWR);
andrewcrussell 1:ecf8078bf531 236 for (m=0;m<481;m++) {
andrewcrussell 1:ecf8078bf531 237 for (n=0;n<641;n++) {
andrewcrussell 1:ecf8078bf531 238 SendData(color);
andrewcrussell 1:ecf8078bf531 239 }
andrewcrussell 1:ecf8078bf531 240 }
andrewcrussell 1:ecf8078bf531 241 }
andrewcrussell 1:ecf8078bf531 242 /**********************************************************************************/
andrewcrussell 1:ecf8078bf531 243 /********** this routine lights up a single pixel to a specific colour ***********/
andrewcrussell 1:ecf8078bf531 244 void LCDSetPixel(int x,int y, int color) {
andrewcrussell 1:ecf8078bf531 245 Write_Command(CASET); //SET page address
andrewcrussell 1:ecf8078bf531 246 Write_Data((x)>>8); //SET start page address=0
andrewcrussell 1:ecf8078bf531 247 Write_Data(x);
andrewcrussell 1:ecf8078bf531 248 Write_Data((XMAX)>>8); //SET end page address=XMAX
andrewcrussell 1:ecf8078bf531 249 Write_Data(XMAX);
andrewcrussell 1:ecf8078bf531 250 Write_Command(PASET); //SET column address
andrewcrussell 1:ecf8078bf531 251 Write_Data((y)>>8); //SET start column address=0
andrewcrussell 1:ecf8078bf531 252 Write_Data(y);
andrewcrussell 1:ecf8078bf531 253 Write_Data((YMAX)>>8); //SET end column address=YMAX
andrewcrussell 1:ecf8078bf531 254 Write_Data(YMAX);
andrewcrussell 1:ecf8078bf531 255 Write_Command(RAMWR); //ready to now start writing the data
andrewcrussell 1:ecf8078bf531 256 //when returnung to the caller
andrewcrussell 1:ecf8078bf531 257 SendData(color);
andrewcrussell 1:ecf8078bf531 258 Write_Command(NOP);
andrewcrussell 1:ecf8078bf531 259 }
andrewcrussell 1:ecf8078bf531 260 /*********************************************************************************/
andrewcrussell 1:ecf8078bf531 261 /************ This routine draws a line between 2 points on the screen ***********/
andrewcrussell 1:ecf8078bf531 262 void LCDSetLine(int x0, int y0, int x1,int y1, int color) {
andrewcrussell 1:ecf8078bf531 263 int dy = y1 - y0;
andrewcrussell 1:ecf8078bf531 264 int dx = x1 - x0;
andrewcrussell 1:ecf8078bf531 265 int stepx, stepy;
andrewcrussell 1:ecf8078bf531 266 if (dy < 0) {
andrewcrussell 1:ecf8078bf531 267 dy = -dy;
andrewcrussell 1:ecf8078bf531 268 stepy = -1;
andrewcrussell 1:ecf8078bf531 269 } else {
andrewcrussell 1:ecf8078bf531 270 stepy = 1;
andrewcrussell 1:ecf8078bf531 271 }
andrewcrussell 1:ecf8078bf531 272 if (dx < 0) {
andrewcrussell 1:ecf8078bf531 273 dx = -dx;
andrewcrussell 1:ecf8078bf531 274 stepx = -1;
andrewcrussell 1:ecf8078bf531 275 } else {
andrewcrussell 1:ecf8078bf531 276 stepx = 1;
andrewcrussell 1:ecf8078bf531 277 }
andrewcrussell 1:ecf8078bf531 278 dy <<= 1; // dy is now 2*dy
andrewcrussell 1:ecf8078bf531 279 dx <<= 1; // dx is now 2*dx
andrewcrussell 1:ecf8078bf531 280 LCDSetPixel(x0, y0, color);
andrewcrussell 1:ecf8078bf531 281 if (dx > dy) {
andrewcrussell 1:ecf8078bf531 282 int fraction = dy - (dx >> 1); // same as 2*dy - dx
andrewcrussell 1:ecf8078bf531 283 while (x0 != x1) {
andrewcrussell 1:ecf8078bf531 284 if (fraction >= 0) {
andrewcrussell 1:ecf8078bf531 285 y0 += stepy;
andrewcrussell 1:ecf8078bf531 286 fraction -= dx; // same as fraction -= 2*dx
andrewcrussell 1:ecf8078bf531 287 }
andrewcrussell 1:ecf8078bf531 288 x0 += stepx;
andrewcrussell 1:ecf8078bf531 289 fraction += dy; // same as fraction -= 2*dy
andrewcrussell 1:ecf8078bf531 290 LCDSetPixel(x0, y0, color);
andrewcrussell 1:ecf8078bf531 291 }
andrewcrussell 1:ecf8078bf531 292 } else {
andrewcrussell 1:ecf8078bf531 293 int fraction = dx - (dy >> 1);
andrewcrussell 1:ecf8078bf531 294 while (y0 != y1) {
andrewcrussell 1:ecf8078bf531 295 if (fraction >= 0) {
andrewcrussell 1:ecf8078bf531 296 x0 += stepx;
andrewcrussell 1:ecf8078bf531 297 fraction -= dy;
andrewcrussell 1:ecf8078bf531 298 }
andrewcrussell 1:ecf8078bf531 299 y0 += stepy;
andrewcrussell 1:ecf8078bf531 300 fraction += dx;
andrewcrussell 1:ecf8078bf531 301 LCDSetPixel(x0, y0, color);
andrewcrussell 1:ecf8078bf531 302 }
andrewcrussell 1:ecf8078bf531 303 }
andrewcrussell 1:ecf8078bf531 304 }
andrewcrussell 1:ecf8078bf531 305 /*******************************************************************************/
andrewcrussell 1:ecf8078bf531 306 /************** draw a rectangle, filled or not filled *************************/
andrewcrussell 1:ecf8078bf531 307 void LCDSetRect(int x0, int y0, int x1,int y1, int fill, int color) {
andrewcrussell 1:ecf8078bf531 308 int xmin, xmax, ymin, ymax;
andrewcrussell 1:ecf8078bf531 309 int i;
andrewcrussell 1:ecf8078bf531 310 // check if the rectangle is to be filled
andrewcrussell 1:ecf8078bf531 311 if (fill == TRUE) {
andrewcrussell 1:ecf8078bf531 312 // calculate the min and max for x and y directions
andrewcrussell 1:ecf8078bf531 313 xmin = (x0 <= x1) ? x0 : x1;
andrewcrussell 1:ecf8078bf531 314 xmax = (x0 > x1) ? x0 : x1;
andrewcrussell 1:ecf8078bf531 315 ymin = (y0 <= y1) ? y0 : y1;
andrewcrussell 1:ecf8078bf531 316 ymax = (y0 > y1) ? y0 : y1;
andrewcrussell 1:ecf8078bf531 317 Write_Command(CASET); //SET page address
andrewcrussell 1:ecf8078bf531 318 Write_Data((x0)>>8); //SET start page address=0
andrewcrussell 1:ecf8078bf531 319 Write_Data(x0);
andrewcrussell 1:ecf8078bf531 320 Write_Data((x1)>>8); //SET end page address=XMAX
andrewcrussell 1:ecf8078bf531 321 Write_Data(x1);
andrewcrussell 1:ecf8078bf531 322 Write_Command(PASET); //SET column address
andrewcrussell 1:ecf8078bf531 323 Write_Data((y0)>>8); //SET start column address=0
andrewcrussell 1:ecf8078bf531 324 Write_Data(y0);
andrewcrussell 1:ecf8078bf531 325 Write_Data((y1)>>8); //SET end column address=YMAX
andrewcrussell 1:ecf8078bf531 326 Write_Data(y1);
andrewcrussell 1:ecf8078bf531 327 Write_Command(RAMWR); //ready to now start writing the data
andrewcrussell 1:ecf8078bf531 328 for (i = 0; i < ((((xmax - xmin + 1) * (ymax - ymin + 1))) + 1); i++) {
andrewcrussell 1:ecf8078bf531 329 SendData(color);
andrewcrussell 1:ecf8078bf531 330 }
andrewcrussell 1:ecf8078bf531 331 } else {
andrewcrussell 1:ecf8078bf531 332 LCDSetLine(x0, y0, x1, y0, color);
andrewcrussell 1:ecf8078bf531 333 LCDSetLine(x0, y1, x1, y1, color);
andrewcrussell 1:ecf8078bf531 334 LCDSetLine(x0, y0, x0, y1, color);
andrewcrussell 1:ecf8078bf531 335 LCDSetLine(x1, y0, x1, y1, color);
andrewcrussell 1:ecf8078bf531 336 }
andrewcrussell 1:ecf8078bf531 337 }
andrewcrussell 1:ecf8078bf531 338 /***************************************************************************/
andrewcrussell 1:ecf8078bf531 339 void LCDSetCircle(int x0, int y0, int radius, int color) {
andrewcrussell 1:ecf8078bf531 340 int f = 1 - radius;
andrewcrussell 1:ecf8078bf531 341 int ddF_x = 0;
andrewcrussell 1:ecf8078bf531 342 int ddF_y = -2 * radius;
andrewcrussell 1:ecf8078bf531 343 int x = 0;
andrewcrussell 1:ecf8078bf531 344 int y = radius;
andrewcrussell 1:ecf8078bf531 345 LCDSetPixel(x0, y0 + radius, color);
andrewcrussell 1:ecf8078bf531 346 LCDSetPixel(x0, y0 - radius, color);
andrewcrussell 1:ecf8078bf531 347 LCDSetPixel(x0 + radius, y0, color);
andrewcrussell 1:ecf8078bf531 348 LCDSetPixel(x0 - radius, y0, color);
andrewcrussell 1:ecf8078bf531 349 while (x < y) {
andrewcrussell 1:ecf8078bf531 350 if (f >= 0) {
andrewcrussell 1:ecf8078bf531 351 y--;
andrewcrussell 1:ecf8078bf531 352 ddF_y += 2;
andrewcrussell 1:ecf8078bf531 353 f += ddF_y;
andrewcrussell 1:ecf8078bf531 354 }
andrewcrussell 1:ecf8078bf531 355 x++;
andrewcrussell 1:ecf8078bf531 356 ddF_x += 2;
andrewcrussell 1:ecf8078bf531 357 f += ddF_x + 1;
andrewcrussell 1:ecf8078bf531 358 LCDSetPixel(x0 + x, y0 + y, color);
andrewcrussell 1:ecf8078bf531 359 LCDSetPixel(x0 - x, y0 + y, color);
andrewcrussell 1:ecf8078bf531 360 LCDSetPixel(x0 + x, y0 - y, color);
andrewcrussell 1:ecf8078bf531 361 LCDSetPixel(x0 - x, y0 - y, color);
andrewcrussell 1:ecf8078bf531 362 LCDSetPixel(x0 + y, y0 + x, color);
andrewcrussell 1:ecf8078bf531 363 LCDSetPixel(x0 - y, y0 + x, color);
andrewcrussell 1:ecf8078bf531 364 LCDSetPixel(x0 + y, y0 - x, color);
andrewcrussell 1:ecf8078bf531 365 LCDSetPixel(x0 - y, y0 - x, color);
andrewcrussell 1:ecf8078bf531 366 }
andrewcrussell 1:ecf8078bf531 367 }
andrewcrussell 1:ecf8078bf531 368 /***************************************************************************/
andrewcrussell 1:ecf8078bf531 369 /***************** this is the mini-font version ***************************/
andrewcrussell 1:ecf8078bf531 370 void LCDPutChar(char c, int x, int y, int size, int fColor, int bColor) {
andrewcrussell 1:ecf8078bf531 371 extern const unsigned char FONT6x8[97][8];
andrewcrussell 1:ecf8078bf531 372 extern const unsigned char FONT8x8[97][8];
andrewcrussell 1:ecf8078bf531 373 extern const unsigned char FONT8x16[97][16];
andrewcrussell 1:ecf8078bf531 374 extern const unsigned char FONT24x59[1][177];
andrewcrussell 1:ecf8078bf531 375
andrewcrussell 1:ecf8078bf531 376 int i,j;
andrewcrussell 1:ecf8078bf531 377 unsigned int nCols;
andrewcrussell 1:ecf8078bf531 378 unsigned int nRows;
andrewcrussell 1:ecf8078bf531 379 unsigned int nBytes;
andrewcrussell 1:ecf8078bf531 380 unsigned char PixelRow;
andrewcrussell 1:ecf8078bf531 381 unsigned char Mask;
andrewcrussell 1:ecf8078bf531 382 unsigned int Word0;
andrewcrussell 1:ecf8078bf531 383 unsigned char *pFont;
andrewcrussell 1:ecf8078bf531 384 unsigned char *pChar;
andrewcrussell 1:ecf8078bf531 385 unsigned char *FontTable[] = {
andrewcrussell 1:ecf8078bf531 386 (unsigned char *)FONT6x8,
andrewcrussell 1:ecf8078bf531 387 (unsigned char *)FONT8x8,
andrewcrussell 1:ecf8078bf531 388 (unsigned char *)FONT8x16,
andrewcrussell 1:ecf8078bf531 389 (unsigned char *)FONT24x59 // I added this - it is just for the zero
andrewcrussell 1:ecf8078bf531 390 };
andrewcrussell 1:ecf8078bf531 391 // get pointer to the beginning of the selected font table
andrewcrussell 1:ecf8078bf531 392 pFont = (unsigned char *)FontTable[size];
andrewcrussell 1:ecf8078bf531 393 // get the nColumns, nRows and nBytes in the font table
andrewcrussell 1:ecf8078bf531 394 nCols = *pFont;
andrewcrussell 1:ecf8078bf531 395 nRows = *(pFont + 1);
andrewcrussell 1:ecf8078bf531 396 nBytes = *(pFont + 2);
andrewcrussell 1:ecf8078bf531 397 // get pointer to the last byte of the desired character - i.e. last byte in the row
andrewcrussell 1:ecf8078bf531 398 pChar = pFont + (nBytes * (c - 0x1F)) + nBytes - 1;
andrewcrussell 1:ecf8078bf531 399
andrewcrussell 1:ecf8078bf531 400 WindowSet( x, (x + nRows - 1), y, (y + nCols - 1) ); // set window (drawing rectangle) to font size
andrewcrussell 1:ecf8078bf531 401 Write_Command(RAMWR);
andrewcrussell 1:ecf8078bf531 402
andrewcrussell 1:ecf8078bf531 403 for ( i = (nRows - 1); i >= 0; i-- ) {
andrewcrussell 1:ecf8078bf531 404 PixelRow = *pChar--;
andrewcrussell 1:ecf8078bf531 405 Mask = 0x80;
andrewcrussell 1:ecf8078bf531 406
andrewcrussell 1:ecf8078bf531 407 for ( j = 0; j < nCols; j++ ) {
andrewcrussell 1:ecf8078bf531 408
andrewcrussell 1:ecf8078bf531 409 Word0 = (PixelRow & Mask) ? fColor : bColor;
andrewcrussell 1:ecf8078bf531 410 Mask = Mask >> 1;
andrewcrussell 1:ecf8078bf531 411
andrewcrussell 1:ecf8078bf531 412 Write_Data( (Word0 >> 16) & 0xFF );
andrewcrussell 1:ecf8078bf531 413 Write_Data( (Word0 >> 8) & 0xFF );
andrewcrussell 1:ecf8078bf531 414 Write_Data( (Word0 ) & 0xFF );
andrewcrussell 1:ecf8078bf531 415 }
andrewcrussell 1:ecf8078bf531 416 }
andrewcrussell 1:ecf8078bf531 417 Write_Command(NOP);// this terminates the Write Memory command
andrewcrussell 1:ecf8078bf531 418 }
andrewcrussell 1:ecf8078bf531 419 /*****************************************************************************/
andrewcrussell 1:ecf8078bf531 420 /***************** this is the mini-font version ***************************/
andrewcrussell 1:ecf8078bf531 421 void LCDPutStr(char *pString, int x, int y, int Size, int fColor, int bColor) {
andrewcrussell 1:ecf8078bf531 422 // loop until null-terminator is seen
andrewcrussell 1:ecf8078bf531 423 while (*pString != 0x00) {
andrewcrussell 1:ecf8078bf531 424 // draw the character
andrewcrussell 1:ecf8078bf531 425 LCDPutChar(*pString++, y, x, Size, fColor, bColor);
andrewcrussell 1:ecf8078bf531 426 // advance the y position
andrewcrussell 1:ecf8078bf531 427 if (Size == 0)// small
andrewcrussell 1:ecf8078bf531 428 y = y + 6;
andrewcrussell 1:ecf8078bf531 429 else if (Size == 1) //medium
andrewcrussell 1:ecf8078bf531 430 y = y + 8;
andrewcrussell 1:ecf8078bf531 431 else if (Size == 2) //large
andrewcrussell 1:ecf8078bf531 432 y = y + 16;
andrewcrussell 1:ecf8078bf531 433 else if (Size == 3)
andrewcrussell 1:ecf8078bf531 434 y = y + 24; //large1
andrewcrussell 1:ecf8078bf531 435 if (y > 640) break; //bail out if it exceeds screen width
andrewcrussell 1:ecf8078bf531 436 }
andrewcrussell 1:ecf8078bf531 437 }
andrewcrussell 1:ecf8078bf531 438 /******************************** square button ***********************/
andrewcrussell 1:ecf8078bf531 439 void sqbutton1(unsigned int x0, unsigned int y0, unsigned int fill, unsigned int color) {
andrewcrussell 1:ecf8078bf531 440 unsigned int xmin, xmax, ymin, ymax;
andrewcrussell 1:ecf8078bf531 441 int i;
andrewcrussell 1:ecf8078bf531 442
andrewcrussell 1:ecf8078bf531 443 // check if the rectangle is to be filled
andrewcrussell 1:ecf8078bf531 444 if (fill == TRUE) {
andrewcrussell 1:ecf8078bf531 445 // best way to create a filled rectangle is to define a drawing box
andrewcrussell 1:ecf8078bf531 446 // and loop two pixels at a time
andrewcrussell 1:ecf8078bf531 447 // calculate the min and max for x and y directions
andrewcrussell 1:ecf8078bf531 448 xmin = (x0 <= (x0 + xbutsize1)) ? x0 : (x0 + xbutsize1);
andrewcrussell 1:ecf8078bf531 449 xmax = (x0 > (x0 + xbutsize1)) ? x0 : (x0 + xbutsize1);
andrewcrussell 1:ecf8078bf531 450 ymin = (y0 <= (y0+ybutsize1)) ? y0 : (y0+ybutsize1);
andrewcrussell 1:ecf8078bf531 451 ymax = (y0 > (y0+ybutsize1)) ? y0 : (y0+ybutsize1);
andrewcrussell 1:ecf8078bf531 452 Write_Command(CASET); //SET page address
andrewcrussell 1:ecf8078bf531 453 Write_Data((x0)>>8); //SET start page address=0
andrewcrussell 1:ecf8078bf531 454 Write_Data(x0);
andrewcrussell 1:ecf8078bf531 455 Write_Data((x0 + xbutsize1)>>8); //SET end page address=XMAX
andrewcrussell 1:ecf8078bf531 456 Write_Data (x0 + xbutsize1);
andrewcrussell 1:ecf8078bf531 457 Write_Command(PASET); //SET column address
andrewcrussell 1:ecf8078bf531 458 Write_Data((y0)>>8); //SET start column address=0
andrewcrussell 1:ecf8078bf531 459 Write_Data(y0);
andrewcrussell 1:ecf8078bf531 460 Write_Data((y0+ybutsize1)>>8); //SET end column address=YMAX
andrewcrussell 1:ecf8078bf531 461 Write_Data (y0+ybutsize1);
andrewcrussell 1:ecf8078bf531 462 Write_Command(RAMWR); //ready to now start writing the data
andrewcrussell 1:ecf8078bf531 463 for (i = 0; i < ((((xmax - xmin + 1) * (ymax - ymin + 1))) + 1); i++) {
andrewcrussell 1:ecf8078bf531 464 SendData(color);
andrewcrussell 1:ecf8078bf531 465 }
andrewcrussell 1:ecf8078bf531 466 } else {
andrewcrussell 1:ecf8078bf531 467 //LCDSetLine(x0, y0, x1, y0, color);
andrewcrussell 1:ecf8078bf531 468 //LCDSetLine(x0, y1, x1, y1, color);
andrewcrussell 1:ecf8078bf531 469 //LCDSetLine(x0, y0, x0, y1, color);
andrewcrussell 1:ecf8078bf531 470 // LCDSetLine(x1, y0, x1, y1, color);
andrewcrussell 1:ecf8078bf531 471
andrewcrussell 1:ecf8078bf531 472 /***************************/
andrewcrussell 1:ecf8078bf531 473 LCDSetLine(x0, y0, (x0 + xbutsize1), y0, color);
andrewcrussell 1:ecf8078bf531 474 LCDSetLine(x0, (y0+ybutsize1), (x0 + xbutsize1), (y0+ybutsize1), color);
andrewcrussell 1:ecf8078bf531 475 LCDSetLine(x0, y0, x0, (y0+ybutsize1), color);
andrewcrussell 1:ecf8078bf531 476 LCDSetLine((x0 + xbutsize1), y0, (x0 + xbutsize1), (y0+ybutsize1), color);
andrewcrussell 1:ecf8078bf531 477 }
andrewcrussell 1:ecf8078bf531 478 }
andrewcrussell 1:ecf8078bf531 479
andrewcrussell 1:ecf8078bf531 480 /**************************************** volume slider ******************************************/
andrewcrussell 1:ecf8078bf531 481 void volume_slider(int volume) { //was float
andrewcrussell 1:ecf8078bf531 482 int slider;
andrewcrussell 1:ecf8078bf531 483 int pos;
andrewcrussell 1:ecf8078bf531 484 //volume=255-volume;
andrewcrussell 1:ecf8078bf531 485 //printf("%u\n\r",volume);
andrewcrussell 1:ecf8078bf531 486 //LCDSetRect((ZERO-10),37,(SPAN+ZERO+10),73,1,BLACK); //erase the previous slider button position
andrewcrussell 1:ecf8078bf531 487 pos = (volume*451)/255;
andrewcrussell 1:ecf8078bf531 488 //pos = volume*(1/254);
andrewcrussell 1:ecf8078bf531 489 slider = ZERO+pos; //((volume/255)*SPAN);
andrewcrussell 1:ecf8078bf531 490 //printf("%u %u\n\r",volume, slider);
andrewcrussell 1:ecf8078bf531 491 LCDSetRect((ZERO-10),37,(SPAN+ZERO+10),60,1,BLACK); //erase the previous slider button position
andrewcrussell 1:ecf8078bf531 492 // here we change the colour of the slider bar depending upn the level
andrewcrussell 1:ecf8078bf531 493 if (slider<237)
andrewcrussell 1:ecf8078bf531 494 LCDSetRect(slider,40,(slider+10),60,1,BLUE);
andrewcrussell 1:ecf8078bf531 495 else if (slider<420)
andrewcrussell 1:ecf8078bf531 496 LCDSetRect(slider,40,(slider+10),60,1,WHITE);
andrewcrussell 1:ecf8078bf531 497 else if (slider<470)
andrewcrussell 1:ecf8078bf531 498 LCDSetRect(slider,40,(slider+10),60,1,YELLOW);
andrewcrussell 1:ecf8078bf531 499 else if (slider<580)
andrewcrussell 1:ecf8078bf531 500 LCDSetRect(slider,40,(slider+10),60,1,RED);
andrewcrussell 1:ecf8078bf531 501 }
andrewcrussell 1:ecf8078bf531 502 /*************************************************************************************************/
andrewcrussell 1:ecf8078bf531 503 /***************************** this is the main central button ******************************/
andrewcrussell 1:ecf8078bf531 504 void big_button(void) {
andrewcrussell 1:ecf8078bf531 505 int z;
andrewcrussell 1:ecf8078bf531 506 for (z=117;z<122;z++) {
andrewcrussell 1:ecf8078bf531 507 LCDSetCircle(320,240,z,WHITE);
andrewcrussell 1:ecf8078bf531 508 }
andrewcrussell 1:ecf8078bf531 509 for (z=130;z<133;z++) {
andrewcrussell 1:ecf8078bf531 510 LCDSetCircle(320,240,z,WHITE);
andrewcrussell 1:ecf8078bf531 511 }
andrewcrussell 1:ecf8078bf531 512 }
andrewcrussell 1:ecf8078bf531 513 /*************************************************************************************************/
andrewcrussell 1:ecf8078bf531 514 void volume_display_window(void) {
andrewcrussell 1:ecf8078bf531 515 LCDSetRect(223,198,418,283,0,WHITE);
andrewcrussell 1:ecf8078bf531 516 }
andrewcrussell 1:ecf8078bf531 517 /*************************************************************************************************/
andrewcrussell 1:ecf8078bf531 518 void slider_bar(void) {
andrewcrussell 1:ecf8078bf531 519
andrewcrussell 1:ecf8078bf531 520 LCDSetRect(100, 20,560,30,0,WHITE);//slider scale volume bar
andrewcrussell 1:ecf8078bf531 521 LCDPutStr("Mute -80 -60 -40 -20 0 +6 +12 +20 +30",10,100,MEDIUM, WHITE,BLACK);//slider scale
andrewcrussell 1:ecf8078bf531 522
andrewcrussell 1:ecf8078bf531 523 }
andrewcrussell 1:ecf8078bf531 524 /*************************************************************************************************/
andrewcrussell 1:ecf8078bf531 525 void input_sel_window(void) {
andrewcrussell 1:ecf8078bf531 526 LCDSetRect(180,380,460,460,0,WHITE);// input select window
andrewcrussell 1:ecf8078bf531 527 }
andrewcrussell 1:ecf8078bf531 528 /*************************************************************************************************/
andrewcrussell 1:ecf8078bf531 529 void input_buttons(void) {
andrewcrussell 1:ecf8078bf531 530 // int righttbutinc=76;
andrewcrussell 1:ecf8078bf531 531 // int xref2=590;
andrewcrussell 1:ecf8078bf531 532 LCDSetCircle(xref2,(1*righttbutinc),25,WHITE);
andrewcrussell 1:ecf8078bf531 533 FontDrawString("CD",(xref2-75),(righttbutinc-20),WHITE,BLACK,&Calibri28);
andrewcrussell 1:ecf8078bf531 534
andrewcrussell 1:ecf8078bf531 535 LCDSetCircle(xref2,(2*righttbutinc),25,WHITE);
andrewcrussell 1:ecf8078bf531 536 FontDrawString("Aux2",(xref2-108),((2*righttbutinc)-20),WHITE,BLACK,&Calibri28);
andrewcrussell 1:ecf8078bf531 537
andrewcrussell 1:ecf8078bf531 538 LCDSetCircle(xref2,(3*righttbutinc),25,WHITE);
andrewcrussell 1:ecf8078bf531 539 FontDrawString("Aux1",(xref2-108),((3*righttbutinc)-20),WHITE,BLACK,&Calibri28);
andrewcrussell 1:ecf8078bf531 540
andrewcrussell 1:ecf8078bf531 541 LCDSetCircle(xref2,(4*righttbutinc),25,WHITE);
andrewcrussell 1:ecf8078bf531 542 FontDrawString("Recdr",(xref2-122),((4*righttbutinc)-20),WHITE,BLACK,&Calibri28);
andrewcrussell 1:ecf8078bf531 543
andrewcrussell 1:ecf8078bf531 544 LCDSetCircle(xref2,(5*righttbutinc),25,WHITE);
andrewcrussell 1:ecf8078bf531 545 FontDrawString("Phono",(xref2-132),((5*righttbutinc)-20),WHITE,BLACK,&Calibri28);
andrewcrussell 1:ecf8078bf531 546 }
andrewcrussell 1:ecf8078bf531 547
andrewcrussell 1:ecf8078bf531 548 /*************************************************************************************************/
andrewcrussell 1:ecf8078bf531 549 void phono_d(int onoff) {
andrewcrussell 1:ecf8078bf531 550 int circinc;
andrewcrussell 1:ecf8078bf531 551 if (onoff==0) {
andrewcrussell 1:ecf8078bf531 552 for (circinc=1;circinc<27;circinc++) {
andrewcrussell 1:ecf8078bf531 553 LCDSetCircle(xref2,(5*righttbutinc),circinc,BLACK);
andrewcrussell 1:ecf8078bf531 554 } //first erase the button
andrewcrussell 1:ecf8078bf531 555
andrewcrussell 1:ecf8078bf531 556 LCDSetCircle(xref2,(5*righttbutinc),25,WHITE);
andrewcrussell 1:ecf8078bf531 557 } //now draw it in outline = OFF
andrewcrussell 1:ecf8078bf531 558
andrewcrussell 1:ecf8078bf531 559 else {
andrewcrussell 1:ecf8078bf531 560 for (circinc=1;circinc<26;circinc++) { //so onoff must have been TRUE
andrewcrussell 1:ecf8078bf531 561 LCDSetCircle(xref2,(5*righttbutinc),circinc,GREEN); //it on so draw it in GREEN
andrewcrussell 1:ecf8078bf531 562 }
andrewcrussell 1:ecf8078bf531 563 }
andrewcrussell 1:ecf8078bf531 564 }
andrewcrussell 1:ecf8078bf531 565 /*************************************************************************************************/
andrewcrussell 1:ecf8078bf531 566 void AUX1(int onoff) {
andrewcrussell 1:ecf8078bf531 567 int circinc;
andrewcrussell 1:ecf8078bf531 568 if (onoff==0) {
andrewcrussell 1:ecf8078bf531 569 for (circinc=1;circinc<27;circinc++) {
andrewcrussell 1:ecf8078bf531 570 LCDSetCircle(xref2,(3*righttbutinc),circinc,BLACK);
andrewcrussell 1:ecf8078bf531 571 } //first erase the button
andrewcrussell 1:ecf8078bf531 572
andrewcrussell 1:ecf8078bf531 573 LCDSetCircle(xref2,(3*righttbutinc),25,WHITE);
andrewcrussell 1:ecf8078bf531 574 } //now draw it in outline = OFF
andrewcrussell 1:ecf8078bf531 575
andrewcrussell 1:ecf8078bf531 576 else {
andrewcrussell 1:ecf8078bf531 577 for (circinc=1;circinc<26;circinc++) { //so onoff must have been TRUE
andrewcrussell 1:ecf8078bf531 578 LCDSetCircle(xref2,(3*righttbutinc),circinc,GREEN); //it on so draw it in GREEN
andrewcrussell 1:ecf8078bf531 579 }
andrewcrussell 1:ecf8078bf531 580 }
andrewcrussell 1:ecf8078bf531 581 }
andrewcrussell 1:ecf8078bf531 582 /*************************************************************************************************/
andrewcrussell 1:ecf8078bf531 583 void AUX2(int onoff) {
andrewcrussell 1:ecf8078bf531 584 int circinc;
andrewcrussell 1:ecf8078bf531 585 if (onoff==0) {
andrewcrussell 1:ecf8078bf531 586 for (circinc=1;circinc<27;circinc++) {
andrewcrussell 1:ecf8078bf531 587 LCDSetCircle(xref2,(2*righttbutinc),circinc,BLACK);
andrewcrussell 1:ecf8078bf531 588 } //first erase the button
andrewcrussell 1:ecf8078bf531 589
andrewcrussell 1:ecf8078bf531 590 LCDSetCircle(xref2,(2*righttbutinc),25,WHITE);
andrewcrussell 1:ecf8078bf531 591 } //now draw it in outline = OFF
andrewcrussell 1:ecf8078bf531 592
andrewcrussell 1:ecf8078bf531 593 else {
andrewcrussell 1:ecf8078bf531 594 for (circinc=1;circinc<26;circinc++) { //so onoff must have been TRUE
andrewcrussell 1:ecf8078bf531 595 LCDSetCircle(xref2,(2*righttbutinc),circinc,GREEN); //it on so draw it in GREEN
andrewcrussell 1:ecf8078bf531 596 }
andrewcrussell 1:ecf8078bf531 597 }
andrewcrussell 1:ecf8078bf531 598 }
andrewcrussell 1:ecf8078bf531 599 /*************************************************************************************************/
andrewcrussell 1:ecf8078bf531 600 void CD_d(int onoff) {
andrewcrussell 1:ecf8078bf531 601 int circinc;
andrewcrussell 1:ecf8078bf531 602 if (onoff==0) {
andrewcrussell 1:ecf8078bf531 603 for (circinc=1;circinc<27;circinc++) {
andrewcrussell 1:ecf8078bf531 604 LCDSetCircle(xref2,(1*righttbutinc),circinc,BLACK);
andrewcrussell 1:ecf8078bf531 605 } //first erase the button
andrewcrussell 1:ecf8078bf531 606
andrewcrussell 1:ecf8078bf531 607 LCDSetCircle(xref2,(1*righttbutinc),25,WHITE);
andrewcrussell 1:ecf8078bf531 608 } //now draw it in outline = OFF
andrewcrussell 1:ecf8078bf531 609
andrewcrussell 1:ecf8078bf531 610 else {
andrewcrussell 1:ecf8078bf531 611 for (circinc=1;circinc<26;circinc++) { //so onoff must have been TRUE
andrewcrussell 1:ecf8078bf531 612 LCDSetCircle(xref2,(1*righttbutinc),circinc,GREEN); //it on so draw it in GREEN
andrewcrussell 1:ecf8078bf531 613 }
andrewcrussell 1:ecf8078bf531 614 }
andrewcrussell 1:ecf8078bf531 615 }
andrewcrussell 1:ecf8078bf531 616 /*************************************************************************************************/
andrewcrussell 1:ecf8078bf531 617 void Recorder_d(int onoff) {
andrewcrussell 1:ecf8078bf531 618 int circinc;
andrewcrussell 1:ecf8078bf531 619 if (onoff==0) {
andrewcrussell 1:ecf8078bf531 620 for (circinc=1;circinc<27;circinc++) {
andrewcrussell 1:ecf8078bf531 621 LCDSetCircle(xref2,(4*righttbutinc),circinc,BLACK);
andrewcrussell 1:ecf8078bf531 622 } //first erase the button
andrewcrussell 1:ecf8078bf531 623
andrewcrussell 1:ecf8078bf531 624 LCDSetCircle(xref2,(4*righttbutinc),25,WHITE);
andrewcrussell 1:ecf8078bf531 625 } //now draw it in outline = OFF
andrewcrussell 1:ecf8078bf531 626
andrewcrussell 1:ecf8078bf531 627 else {
andrewcrussell 1:ecf8078bf531 628 for (circinc=1;circinc<26;circinc++) { //so onoff must have been TRUE
andrewcrussell 1:ecf8078bf531 629 LCDSetCircle(xref2,(4*righttbutinc),circinc,GREEN); //it on so draw it in GREEN
andrewcrussell 1:ecf8078bf531 630 }
andrewcrussell 1:ecf8078bf531 631 }
andrewcrussell 1:ecf8078bf531 632 }
andrewcrussell 1:ecf8078bf531 633
andrewcrussell 1:ecf8078bf531 634 /*************************************************************************************************/
andrewcrussell 1:ecf8078bf531 635 void Control_buttons(void) {
andrewcrussell 1:ecf8078bf531 636
andrewcrussell 1:ecf8078bf531 637 sqbutton1(xref1,50,0,WHITE); //mute
andrewcrussell 1:ecf8078bf531 638 FontDrawString("Mute",82,57,WHITE,BLACK,&Calibri28);
andrewcrussell 1:ecf8078bf531 639
andrewcrussell 1:ecf8078bf531 640 sqbutton1(xref1, 126,0,WHITE); //Rec
andrewcrussell 1:ecf8078bf531 641 FontDrawString("Rec",82,128,WHITE,BLACK,&Calibri28); //gap is 66
andrewcrussell 1:ecf8078bf531 642
andrewcrussell 1:ecf8078bf531 643 sqbutton1(xref1,202,0,WHITE); //stdby
andrewcrussell 1:ecf8078bf531 644 FontDrawString("Stdby",82,203,WHITE,BLACK,&Calibri28);
andrewcrussell 1:ecf8078bf531 645
andrewcrussell 1:ecf8078bf531 646 sqbutton1(xref1, 278,0,WHITE);//power amp
andrewcrussell 1:ecf8078bf531 647 FontDrawString("Amp",82,280,WHITE,BLACK,&Calibri28);
andrewcrussell 1:ecf8078bf531 648
andrewcrussell 1:ecf8078bf531 649 //sqbutton1(xref1,400,0,RED); //this is the IR indicator
andrewcrussell 1:ecf8078bf531 650 //FontDrawString("IR",82,400,WHITE,BLACK,&Calibri28);
andrewcrussell 1:ecf8078bf531 651
andrewcrussell 1:ecf8078bf531 652 }
andrewcrussell 1:ecf8078bf531 653 /*************************************************************************************************/
andrewcrussell 1:ecf8078bf531 654 void mute(unsigned int onoff) { //this is the bottom button
andrewcrussell 1:ecf8078bf531 655 if (onoff==0) {
andrewcrussell 1:ecf8078bf531 656 sqbutton1(xref1,50,1,BLACK); //first erase the button
andrewcrussell 1:ecf8078bf531 657 wait_ms(800);
andrewcrussell 1:ecf8078bf531 658 sqbutton1(xref1,50,0,WHITE);
andrewcrussell 1:ecf8078bf531 659 } //now redraw it
andrewcrussell 1:ecf8078bf531 660 else {
andrewcrussell 1:ecf8078bf531 661 sqbutton1(16,50,1,WHITE);
andrewcrussell 1:ecf8078bf531 662 }
andrewcrussell 1:ecf8078bf531 663 }
andrewcrussell 1:ecf8078bf531 664 /*************************************************************************************************/
andrewcrussell 1:ecf8078bf531 665 void record(unsigned int onoff) { //this is the second from bottom button
andrewcrussell 1:ecf8078bf531 666 if (onoff==0) {
andrewcrussell 1:ecf8078bf531 667 sqbutton1(xref1,126,1,BLACK); //first erase the button
andrewcrussell 1:ecf8078bf531 668 wait_ms(800);
andrewcrussell 1:ecf8078bf531 669 sqbutton1(16, 126,0,WHITE);
andrewcrussell 1:ecf8078bf531 670 } //now redraw it
andrewcrussell 1:ecf8078bf531 671 else {
andrewcrussell 1:ecf8078bf531 672 sqbutton1(16,126,1,WHITE);
andrewcrussell 1:ecf8078bf531 673 }
andrewcrussell 1:ecf8078bf531 674 }
andrewcrussell 1:ecf8078bf531 675 /*************************************************************************************************/
andrewcrussell 1:ecf8078bf531 676 void stdby(unsigned int onoff) { //this is the 3rd from bottom button
andrewcrussell 1:ecf8078bf531 677 if (onoff==0) {
andrewcrussell 1:ecf8078bf531 678 sqbutton1(xref1,202,1,BLACK); //first erase the button
andrewcrussell 1:ecf8078bf531 679 wait_ms(800);
andrewcrussell 1:ecf8078bf531 680 sqbutton1(xref1, 202,0,WHITE);
andrewcrussell 1:ecf8078bf531 681 } //now redraw it
andrewcrussell 1:ecf8078bf531 682 else {
andrewcrussell 1:ecf8078bf531 683 sqbutton1(xref1,202,1,WHITE);
andrewcrussell 1:ecf8078bf531 684 }
andrewcrussell 1:ecf8078bf531 685 }
andrewcrussell 1:ecf8078bf531 686 /*************************************************************************************************/
andrewcrussell 1:ecf8078bf531 687 void pwramp(unsigned int onoff) { //this is the top lefthand side button
andrewcrussell 1:ecf8078bf531 688 if (onoff==0) {
andrewcrussell 1:ecf8078bf531 689 sqbutton1(xref1, 278,1,BLACK); //first erase the button
andrewcrussell 1:ecf8078bf531 690 wait_ms(800);
andrewcrussell 1:ecf8078bf531 691 sqbutton1(xref1,278,0,WHITE);
andrewcrussell 1:ecf8078bf531 692 } //now redraw it
andrewcrussell 1:ecf8078bf531 693 else {
andrewcrussell 1:ecf8078bf531 694 sqbutton1(xref1, 278,1,WHITE);
andrewcrussell 1:ecf8078bf531 695 }
andrewcrussell 1:ecf8078bf531 696 }
andrewcrussell 1:ecf8078bf531 697 /*************************************************************************************************/
andrewcrussell 1:ecf8078bf531 698 void infra(unsigned int onoff) { //this is the top lefthand side button
andrewcrussell 1:ecf8078bf531 699 if (onoff==0) {
andrewcrussell 1:ecf8078bf531 700 sqbutton1(xref1, 400,1,BLACK); //first erase the button
andrewcrussell 1:ecf8078bf531 701 wait_ms(800);
andrewcrussell 1:ecf8078bf531 702 sqbutton1(xref1,400,0,RED);
andrewcrussell 1:ecf8078bf531 703 } //now redraw it
andrewcrussell 1:ecf8078bf531 704 else {
andrewcrussell 1:ecf8078bf531 705 sqbutton1(xref1, 400,1,RED);
andrewcrussell 1:ecf8078bf531 706 }
andrewcrussell 1:ecf8078bf531 707 }
andrewcrussell 1:ecf8078bf531 708 /*************************************************************************************************/
andrewcrussell 1:ecf8078bf531 709 void trigcircle (int xtc, int ytc, int radius, int color) {
andrewcrussell 1:ecf8078bf531 710
andrewcrussell 1:ecf8078bf531 711 double circ;
andrewcrussell 1:ecf8078bf531 712 double cosnum;
andrewcrussell 1:ecf8078bf531 713 double sinum;
andrewcrussell 1:ecf8078bf531 714
andrewcrussell 1:ecf8078bf531 715 // trigcircle (230, 230, 100, WHITE);
andrewcrussell 1:ecf8078bf531 716 for (circ=0;circ<=360;(circ++)) {
andrewcrussell 1:ecf8078bf531 717 sinum=sin(circ)*radius;
andrewcrussell 1:ecf8078bf531 718 cosnum=cos(circ)*radius;
andrewcrussell 1:ecf8078bf531 719 LCDSetLine(xtc,ytc,(sinum+xtc),(cosnum+ytc),WHITE);
andrewcrussell 1:ecf8078bf531 720 }
andrewcrussell 1:ecf8078bf531 721
andrewcrussell 1:ecf8078bf531 722 }
andrewcrussell 1:ecf8078bf531 723
andrewcrussell 1:ecf8078bf531 724 /**************************************************************************************/
andrewcrussell 1:ecf8078bf531 725
andrewcrussell 1:ecf8078bf531 726 void clear_input_select(void){
andrewcrussell 1:ecf8078bf531 727
andrewcrussell 1:ecf8078bf531 728 int circinc;
andrewcrussell 1:ecf8078bf531 729 for (circinc=1;circinc<24;circinc++) {
andrewcrussell 1:ecf8078bf531 730
andrewcrussell 1:ecf8078bf531 731 LCDSetCircle(xref2,(5*righttbutinc),circinc,BLACK); //phono
andrewcrussell 1:ecf8078bf531 732 LCDSetCircle(xref2,(3*righttbutinc),circinc,BLACK); //aux1
andrewcrussell 1:ecf8078bf531 733 LCDSetCircle(xref2,(2*righttbutinc),circinc,BLACK); //aux2
andrewcrussell 1:ecf8078bf531 734 LCDSetCircle(xref2,(1*righttbutinc),circinc,BLACK); //CD
andrewcrussell 1:ecf8078bf531 735 LCDSetCircle(xref2,(4*righttbutinc),circinc,BLACK); //recorder
andrewcrussell 1:ecf8078bf531 736 }
andrewcrussell 1:ecf8078bf531 737 }