Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of Digital_project by
Diff: LCD4884.cpp
- Revision:
- 2:6b2526c99e5c
- Parent:
- 1:a4c852d25ead
--- a/LCD4884.cpp Mon Dec 07 16:12:55 2015 +0000
+++ b/LCD4884.cpp Wed Dec 09 10:55:01 2015 +0000
@@ -17,11 +17,12 @@
#include <SPI.h>
DigitalOut SpiClk(D2); //2- Serial Clock(Master Output)
-DigitalOut SpiMosi(D3); //3- Master Output,Slave Input
-DigitalOut LcdDC(D4); //4- Data/Command(command active low)
-DigitalOut SpiCS(D5); //5- Chip Select,Slave Transmit Enable(active low,Master Output)
+DigitalOut SpiMosi(D3); //3- Master Output,Slave Input
+DigitalOut LcdDC(D4); //4- Data/Command(command active low)
+DigitalOut SpiCS(D5); //5- Chip Select,Slave Transmit Enable(active low,Master Output)
DigitalOut LcdRst(D6); //6- One Reset button
-PwmOut LcdBl(D7); //7- LCD backlight
+PwmOut LcdBl(D7); //7- LCD backlight
+AnalogIn JoyStick(A0); //8- JoyStick analog input
LCD4884::LCD4884()
{};
@@ -163,4 +164,84 @@
LCD_write_byte(Pix,1);
printf("%d %d %d\n",X,line,Pix);
wait_ms(10);
+}
+/******************************************************************/
+/* write char in big font */
+void LCD4884::LCD_write_char_big (unsigned char X,unsigned char Y, unsigned char ch, char mode)
+{
+ unsigned char i, j;
+ unsigned char *pFont;
+ unsigned char ch_dat;
+
+ pFont = (unsigned char *) big_number;
+
+ if(ch == '.')
+ ch = 10;
+ else if (ch == '+')
+ ch = 11;
+ else if (ch == '-')
+ ch = 12;
+ else
+ ch = ch & 0x0f;
+
+ for(i=0;i<3;i++)
+ {
+ LCD_set_XY ( X, Y+i);
+
+ for(j=0; j<16; j++)
+ {
+ ch_dat = *(pFont+ch*48 + i*16 +j);
+ LCD_write_byte( (mode == MENU_NORMAL)? ch_dat : (ch_dat^0xff), 1);
+ }
+ }
+}
+/******************************************************************/
+void LCD4884::LCD_write_string_big ( unsigned char X,unsigned char Y, char *string, char mode )
+{
+ while ( *string )
+ {
+ LCD_write_char_big( X, Y, *string , mode );
+
+ if(*string++ == '.')
+ X += 5;
+ else
+ X += 12;
+ }
+}
+
+
+/******************************************************************/
+char LCD4884::LCD_joystick()
+{
+ float pos;
+ pos = JoyStick.read();
+ //up = 1.00, down = 0.47, right = 0.73, left = 0.00, middle = 0.79
+ if(pos>0.980000) return 'u';
+ else if(0.460000<pos&&pos<0.480000) return 'd';
+ else if(0.720000<pos&&pos<0.740000) return 'r';
+ else if(0.020000>pos) return 'l';
+ else if(0.770000<pos&&pos<0.810000) return 'm';
+
+}
+/******************************************************************/
+void LCD4884::LCD_draw_bmp_pixel(unsigned char X,unsigned char Y,unsigned char *map,
+ unsigned char Pix_x,unsigned char Pix_y)
+{
+ unsigned int i,n;
+ unsigned char row;
+
+ if (Pix_y%8==0)
+ row=Pix_y/8; //row from 1 to 6;Pix_y from R0 to R47
+ else
+ row=Pix_y/8+1; //Quotient+1
+
+ for (n=0;n<row;n++)
+ {
+ LCD_set_XY(X,Y);
+ for(i=0; i<Pix_x; i++)
+ {
+ LCD_write_byte(map[i+n*Pix_x], 1); // D/C=1:write data to display RAM
+ }
+ Y++;
+ }
}
\ No newline at end of file
