📄 disp_handler.c
字号:
#include "cc2511_app_ex_lib_headers.h"
#include "winamp_remote_control.h"
#include "lcd.h"
const char __code pSplashScreenLine0[] = " Winamp ";
const char __code pSplashScreenLine1[] = " Remote Control ";
#define LCD_SPECIAL_CHAR_COUNT (sizeof(ppLcdSpecialChars) / 8)
const char __code ppLcdSpecialChars[][8] = {
{ 0x00, 0x10, 0x18, 0x1C, 0x18, 0x10, 0x00, 0x00 }, // Play
{ 0x00, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00, 0x00 }, // Stop
{ 0x00, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x00, 0x00 }, // Pause
{ 0x04, 0x06, 0x1F, 0x00, 0x1F, 0x0C, 0x04, 0x00 }, // Shuffle
{ 0x00, 0x00, 0x04, 0x06, 0x1F, 0x00, 0x00, 0x00 }, // Linear
{ 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00 }, // Volume0
{ 0x1F, 0x10, 0x10, 0x10, 0x10, 0x10, 0x1F, 0x00 }, // Volume1
{ 0x1F, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1F, 0x00 }, // Volume2
{ 0x1F, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1F, 0x00 }, // Volume3
{ 0x1F, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1F, 0x00 }, // Volume4
{ 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00 }, // Volume5
};
#define LCD_CHAR_PLAY 0
#define LCD_CHAR_STOP 1
#define LCD_CHAR_PAUSE 2
#define LCD_CHAR_SHUFFLE 3
#define LCD_CHAR_LINEAR 4
#define LCD_CHAR_VOLUME_0 5
#define LCD_CHAR_VOLUME_1 6
#define LCD_CHAR_VOLUME_2 7
#define LCD_CHAR_VOLUME_3 8
#define LCD_CHAR_VOLUME_4 9
#define LCD_CHAR_VOLUME_5 10
#define LCD_OFFSET_STATE 0
#define LCD_OFFSET_SHUFFLE 2
#define LCD_OFFSET_TIME 4
#define LCD_OFFSET_VOLUME 10
void dispInit(void) {
UINT8 address;
UINT8 n;
// Initialize the handlers
initLcd();
// Register special LCD characters
for (n = 0; n < LCD_SPECIAL_CHAR_COUNT; n++) {
address = n * 8;
initNewSymbol((char __xdata * ) &ppLcdSpecialChars[n][0], address);
}
dispSplashScreen();
} // dispInit
void dispSplashScreen(void)
{
// Display the splash screen
lcdUpdate((char __xdata*) pSplashScreenLine0, (char __xdata*) pSplashScreenLine1);
}
static void ByteToDec2(BYTE value, BYTE __xdata *pDec2) {
BYTE dec10;
dec10 = value / 10;
pDec2[0] = dec10 + '0';
pDec2[1] = value - 10 * dec10 + '0';
} // ByteToDec2
void dispRefreshTitle(UINT8 scrollPos) {
lcdUpdateLine(LINE2, &waDispData.pTitle[scrollPos]);
} // dispRefreshTitle
void dispRefreshTime(void) {
UINT8 n;
BYTE lcdData[6];
ByteToDec2(timeData.minutes, &lcdData[0]);
lcdData[2] = ':';
ByteToDec2(timeData.seconds, &lcdData[3]);
lcdData[5] = ' ';
for (n = 0; n < 6; n++) {
lcdUpdateChar(LINE1, LCD_OFFSET_TIME + n, lcdData[n]);
}
} // dispRefreshTime
void dispRefreshShuffle(void) {
if (waDispData.state & WDD_STATE_SHUFFLE_BM) {
lcdUpdateSymbol(LINE1, LCD_OFFSET_SHUFFLE, LCD_CHAR_SHUFFLE);
lcdUpdateChar(LINE1, LCD_OFFSET_SHUFFLE + 1, ' ');
} else {
lcdUpdateSymbol(LINE1, LCD_OFFSET_SHUFFLE, LCD_CHAR_LINEAR);
lcdUpdateChar(LINE1, LCD_OFFSET_SHUFFLE + 1, ' ');
}
} // dispRefreshShuffle
void dispRefreshVolume(void) {
UINT8 totalBarSize;
INT8 smallBarSize;
UINT8 n;
// Constrain the size of the total bar to 0-30
totalBarSize = rcData.volume / 8;
if (totalBarSize > 30) totalBarSize = 30;
for (n = 0; n < 6; n++) {
// Constrain the size of each small bar to 0-5
smallBarSize = totalBarSize - (n * 5);
if (smallBarSize < 0) smallBarSize = 0;
if (smallBarSize > 5) smallBarSize = 5;
// Update the LCD
lcdUpdateSymbol(LINE1, LCD_OFFSET_VOLUME + n, LCD_CHAR_VOLUME_0 + smallBarSize);
}
} // dispRefreshVolume
void dispRefreshState(void) {
if (waDispData.state & WDD_STATE_PLAYING_BM) {
lcdUpdateSymbol(LINE1, LCD_OFFSET_STATE, LCD_CHAR_PLAY);
} else if (waDispData.state & WDD_STATE_PAUSED_BM) {
lcdUpdateSymbol(LINE1, LCD_OFFSET_STATE, LCD_CHAR_PAUSE);
} else {
lcdUpdateSymbol(LINE1, LCD_OFFSET_STATE, LCD_CHAR_STOP);
}
lcdUpdateChar(LINE1, LCD_OFFSET_STATE + 1, ' ');
} // dispRefreshState
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -