|
TIVA C Launchpad周计划——第三周(5110液晶屏)
[复制链接]
用Energia开发环境驱动5110液晶屏,板子上的按键来控制背光的开关,程序是在GitHub上找到的,貌似就是做Energia的人写的,有部分还是用C++写的,还有一些地方没看懂。。。
myScreen.text(0, 2, "LaunchPad")这个函数是用定义的0号字体,在屏幕第二行显示LaunchPad单词,字体和显示行可以自定义,最大字体是2,最多5行 程序还兼容430的launchpad,接线如下 - #if defined(__MSP430G2553__) // LaunchPad MSP430G2553 specific
- LCD_5110::LCD_5110() {
- LCD_5110(P2_2, // Chip Select
- P2_4, // Serial Clock
- P2_0, // Serial Data
- P2_3, // Data/Command
- P1_0, // Reset
- P2_1, // Backlight
- PUSH2); // Push Button 2
- }
- #elif defined(__MSP430G2452__) // LaunchPad MSP430G2452 specific
- LCD_5110::LCD_5110() {
- LCD_5110(P2_2, // Chip Select
- P2_4, // Serial Clock
- P2_0, // Serial Data
- P2_3, // Data/Command
- P1_0, // Reset
- P2_1, // Backlight
- PUSH2); // Push Button 2
- }
- #elif defined(__LM4F120H5QR__) // StellarPad LM4F specific
- LCD_5110::LCD_5110() {
- LCD_5110(PA_7, // Chip Select
- PA_3, // Serial Clock
- PA_5, // Serial Data
- PA_2, // Data/Command
- PB_5, // Reset
- PA_6, // Backlight
- PUSH2); // Push Button 2
- }
- #else
- #error Platform not supported
- #endif
复制代码
- // Include application, user and local libraries
- #include "LCD_5110.h"
- // Variables
- LCD_5110 myScreen;
- boolean backlight = false;
- uint8_t k = 0;
- // Add setup code
- void setup() {
- myScreen.begin();
-
- myScreen.setBacklight(backlight);
- myScreen.text(0, 0, "Hello!");
-
- delay(1000);
- // myScreen.clear();
- myScreen.text(0, 5, "Light off");
- }
- // Add loop code
- void loop() {
- if (myScreen.getButton()) {
- backlight = (backlight==0);
- myScreen.setFont(0);
- myScreen.text(0, 5, backlight ? "Light on " : "Light off");
- myScreen.setBacklight(backlight);
- }
-
- myScreen.setFont(0);
- if (k==0) myScreen.text(0, 2, "Stellaris");
- else if (k==8) myScreen.text(0, 2, "LaunchPad");
-
- myScreen.setFont(0);
- for (uint8_t i=0; i<14; i++) myScreen.text(i, 4, (i==k) ? "*" : " ");
- k++;
- k %= 14;
-
- delay(200);
- }
复制代码
|
|