[X9D] Notification bar

This commit is contained in:
bsongis
2013-03-11 18:49:07 +00:00
parent e9cb986bdf
commit 2abaa19c01
5 changed files with 69 additions and 30 deletions
+2 -2
View File
@@ -636,7 +636,7 @@ void AudioQueue::playFile(const char *filename, uint8_t flags, uint8_t id)
if (flags & PLAY_BACKGROUND) { if (flags & PLAY_BACKGROUND) {
memset(&backgroundContext.fragment, 0, sizeof(AudioFragment)); memset(&backgroundContext.fragment, 0, sizeof(AudioFragment));
strncpy(backgroundContext.fragment.file, filename, 32); strcpy(backgroundContext.fragment.file, filename);
backgroundContext.fragment.id = id; backgroundContext.fragment.id = id;
if (!busy()) { if (!busy()) {
state = AUDIO_RESUMING; state = AUDIO_RESUMING;
@@ -648,7 +648,7 @@ void AudioQueue::playFile(const char *filename, uint8_t flags, uint8_t id)
if (next_widx != ridx) { if (next_widx != ridx) {
AudioFragment & fragment = fragments[widx]; AudioFragment & fragment = fragments[widx];
memset(&fragment, 0, sizeof(fragment)); memset(&fragment, 0, sizeof(fragment));
strcpy(fragment.file, filename); // TODO strncpy strcpy(fragment.file, filename);
fragment.repeat = flags & 0x0f; fragment.repeat = flags & 0x0f;
fragment.id = id; fragment.id = id;
if (flags & PLAY_NOW) if (flags & PLAY_NOW)
+2 -2
View File
@@ -1,2 +1,2 @@
49,8, 102,8,
0x1d,0xe3,0xe3,0x1c,0x1c,0xdd,0xdd,0x3e,0xea,0x23,0x6b,0xb6,0xa1,0x9f,0xbf,0xc0,0xf9,0xef,0xff,0xe8,0xa1,0x9f,0xbf,0xc0,0xea,0x23,0x6b,0xb6,0x1c,0xdd,0xdd,0x3e,0x1d,0xe3,0xe3,0x1c,0x39,0xff,0xff,0x38,0x39,0xbb,0xbb,0x7c,0x7c,0x7d,0x7d,0xfe,0xfe,0xff,0xff,0xfe,0x29,0xd7,0xff,0x00,0x29,0xef,0xef,0x38,0xfe,0x93,0xff,0x92,0x7c,0x45,0x7d,0xc6,0x39,0xbb,0xbb,0x7c,0xff,0xff,0xff,0xff,0xff,0x7f,0x7f,0x7f,0xff,0x41,0x41,0x41,0xff,0x7d,0x7d,0x7d,0xff,0x7d,0x7d,0x7d,0xff,0x7d,0x7d,0x7d,0xff,0x7d,0x7d,0x7d,0xfd,0x7b,0x7b,0x79,0xfb,0x47,0x47,0x43,0xff,0x7f,0x7f,0x7f,0xff,0xff,0xff,0xff,0xff,0x7f,0x7f,0x7f,0xff,0x7f,0x7f,0x7f,0xe3,0x7f,0x77,0x63,0xdd,0x7f,0x63,0x41,0xdd,0x7f,0x41,0x41,0xdd,0x7f,0x63,0x41,0xe3,0x7f,0x77,0x63,0xff,0x7f,0x7f,0x7f,0xff,0x7f,0x7f,0x7f,0xff,0xff,0xff,0xff,0xff,0x7f,0x7f,0x7f,0xfb,0x47,0x47,0x43,0xff,0x7b,0x7b,0x7b,0xdb,0x67,0x67,0x43,0xff,0x5f,0x5f,0x5f,0xff,0x59,0x59,0x59,0xdd,0x67,0x63,0x41,0xff,0x79,0x79,0x79,0xff,0x7f,0x7f,0x7f,0xff,0xff,0xff,0xff, 0x1d,0xe3,0xe3,0x1c,0x1c,0xdd,0xdd,0x3e,0xea,0x23,0x6b,0xb6,0xa1,0x9f,0xbf,0xc0,0xf9,0xef,0xff,0xe8,0xa1,0x9f,0xbf,0xc0,0xea,0x23,0x6b,0xb6,0x1c,0xdd,0xdd,0x3e,0x1d,0xe3,0xe3,0x1c,0x38,0xff,0xff,0x38,0x7c,0xbb,0xbb,0x7c,0xfe,0x7d,0x7d,0xfe,0xfe,0xff,0xff,0xfe,0x00,0xff,0xff,0x00,0x50,0xff,0xff,0x50,0x20,0xff,0xff,0x20,0x50,0xff,0xff,0x50,0x38,0xff,0xff,0x38,0x7c,0xbb,0xbb,0x7c,0xfe,0x7d,0x7d,0xfe,0xfe,0xff,0xff,0xfe,0x00,0xff,0xff,0x00,0x40,0xff,0xff,0x40,0x40,0xff,0xff,0x40,0x40,0xff,0xff,0x40,0x38,0xff,0xff,0x38,0x7c,0xbb,0xbb,0x7c,0xfe,0x7d,0x7d,0xfe,0xfe,0xff,0xff,0xfe,0x00,0xff,0xff,0x00,0x50,0xff,0xff,0x50,0x50,0xff,0xff,0x50,0x50,0xff,0xff,0x50,0x38,0xff,0xff,0x38,0x7c,0xbb,0xbb,0x7c,0xfe,0x7d,0x7d,0xfe,0xfe,0xff,0xff,0xfe,0x00,0xff,0xff,0x00,0x54,0xff,0xff,0x54,0x54,0xff,0xff,0x54,0x54,0xff,0xff,0x54,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x7f,0xff,0xc1,0x41,0x41,0xff,0xfd,0x7d,0x7d,0xff,0xfd,0x7d,0x7d,0xff,0xfd,0x7d,0x7d,0xff,0xfd,0x7d,0x7d,0xfd,0xfb,0x7b,0x79,0xfb,0xc7,0x47,0x43,0xff,0xff,0x7f,0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x7f,0xff,0xff,0x7f,0x7f,0xe3,0xff,0x77,0x63,0xdd,0xff,0x63,0x41,0xdd,0xff,0x41,0x41,0xdd,0xff,0x63,0x41,0xe3,0xff,0x77,0x63,0xff,0xff,0x7f,0x7f,0xff,0xff,0x7f,0x7f,0xff,0xff,0xff,0xff,0xfd,0xff,0x43,0x41,0xff,0xff,0x7d,0x7d,0xff,0xff,0x73,0x73,0xff,0xff,0x7d,0x7d,0xdd,0xff,0x63,0x41,0xff,0xff,0x5f,0x5f,0xff,0xff,0x59,0x59,0xdd,0xff,0x63,0x41,0xff,0xff,0x79,0x79,0xff,0xff,0xff,0xff,0xff,0xff,0x79,0x79,0xdd,0xff,0x63,0x41,0xff,0xff,0x59,0x59,0xff,0xff,0x5f,0x5f,0xf5,0xff,0x5b,0x51,0xff,0xff,0x55,0x55,0xff,0xff,0x55,0x55,0xff,0xff,0x55,0x55,0xd7,0xff,0x6d,0x45,0xff,0xff,0xff,0xff,0xff,0xff,0x63,0x63,0xff,0xff,0x63,0x63,0xff,0xff,0x77,0x77,0xff,0xff,0x73,0x73,0xff,0xff,0x65,0x65,0xfd,0xff,0x57,0x55,0xff,0xff,0x77,0x77,0xff,0xff,0x63,0x63,0xeb,0xff,0x77,0x63,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x7f,0xff,0xff,0x7f,0x7f,0xff,0xff,0x7f,0x7f,0xff,0xff,0x7f,0x7f,0xff,0xff,0x51,0x51,0xff,0xff,0x7f,0x7f,0xff,0xff,0x7f,0x7f,0xff,0xff,0x7f,0x7f,0xff,0xff,0x7f,0x7f,0xff,0xff,0xff,0xff,
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 731 B

After

Width:  |  Height:  |  Size: 765 B

+61 -26
View File
@@ -105,11 +105,17 @@
#include "icons.lbm" #include "icons.lbm"
}; };
#define ICON_RSSI 0, 9 #define ICON_RSSI 0, 9
#define ICON_SPEAKER 9, 9 #define ICON_SPEAKER0 9, 8
#define ICON_SD 18, 11 #define ICON_SPEAKER1 17, 8
#define ICON_LOGS 28, 11 #define ICON_SPEAKER2 25, 8
#define ICON_TRAINER 38, 11 #define ICON_SPEAKER3 33, 8
#define ICON_SD 41, 11
#define ICON_LOGS 51, 11
#define ICON_TRAINER 61, 11
#define ICON_TRAINEE 71, 11
#define ICON_USB 81, 11
#define ICON_REBOOT 91, 11
#endif #endif
void drawPotsBars() void drawPotsBars()
@@ -200,15 +206,15 @@ void displaySliders()
} }
} }
#define BAR_X 15 #define BAR_X 14
#define BAR_Y 1 #define BAR_Y 1
#define BAR_BATT_X BAR_X+19 #define BAR_W 184
#define BAR_H 9
#define BAR_BATT_X BAR_X+18
#define BAR_RSSI_X BAR_X+42 #define BAR_RSSI_X BAR_X+42
#define BAR_SD_X BAR_X+100 #define BAR_NOTIFS_X BAR_X+133
#define BAR_LOGS_X BAR_X+112 #define BAR_VOLUME_X BAR_X+147
#define BAR_TRN_X BAR_X+124 #define BAR_TIME_X BAR_X+168
#define BAR_VOLUME_X BAR_X+140
#define BAR_TIME_X BAR_X+165
void displayTopBarGauge(xcoord_t x, uint8_t count, bool blinking=false) void displayTopBarGauge(xcoord_t x, uint8_t count, bool blinking=false)
{ {
@@ -219,31 +225,60 @@ void displayTopBarGauge(xcoord_t x, uint8_t count, bool blinking=false)
lcd_vline(x+2+i, BAR_Y+3, 3); lcd_vline(x+2+i, BAR_Y+3, 3);
} }
#define LCD_NOTIF_ICON(x, icon) \
lcd_bmp(x, BAR_Y, icons, icon); \
lcd_hline(x, BAR_Y+8, 11)
void displayTopBar() void displayTopBar()
{ {
/* Tx voltage */ /* Tx voltage */
putsVBat(BAR_BATT_X, BAR_Y+1, 0); putsVBat(BAR_BATT_X, BAR_Y+1, 0);
lcd_rect(VBATT_X, BAR_Y+1, 13, 7); lcd_rect(BAR_BATT_X+FW, BAR_Y+1, 13, 7);
lcd_vline(VBATT_X+13, BAR_Y+2, 5); lcd_vline(BAR_BATT_X+FW+13, BAR_Y+2, 5);
/* RSSI */ /* RSSI */
LCD_ICON(BAR_RSSI_X, BAR_Y, ICON_RSSI); LCD_ICON(BAR_RSSI_X, BAR_Y, ICON_RSSI);
lcd_rect(BAR_RSSI_X+10, BAR_Y+1, 13, 7); lcd_rect(BAR_RSSI_X+10, BAR_Y+1, 13, 7);
/* SD icon */ /* Notifs icons */
LCD_ICON(BAR_SD_X, BAR_Y, ICON_SD); xcoord_t x = BAR_NOTIFS_X;
lcd_hline(BAR_SD_X, BAR_Y+8, 11); if (unexpectedShutdown) {
LCD_NOTIF_ICON(x, ICON_REBOOT);
x -= 12;
}
/* Logs icon */ if (1) {
LCD_ICON(BAR_LOGS_X, BAR_Y, ICON_LOGS); LCD_NOTIF_ICON(x, ICON_USB);
lcd_hline(BAR_LOGS_X, BAR_Y+8, 11); x -= 12;
}
/* Trainer icon */ if (SLAVE_MODE()) {
LCD_ICON(BAR_TRN_X, BAR_Y, ICON_TRAINER); LCD_NOTIF_ICON(x, ICON_TRAINEE);
lcd_hline(BAR_TRN_X, BAR_Y+8, 11); x -= 12;
}
else if (1) {
LCD_NOTIF_ICON(x, ICON_TRAINER);
x -= 12;
}
if (isFunctionActive(FUNC_LOGS)) {
LCD_NOTIF_ICON(x, ICON_LOGS);
x -= 12;
}
if (sdMounted()) {
LCD_NOTIF_ICON(x, ICON_SD);
}
/* Audio volume */ /* Audio volume */
LCD_ICON(BAR_VOLUME_X, BAR_Y, ICON_SPEAKER); if (requiredSpeakerVolume == 0)
LCD_ICON(BAR_VOLUME_X, BAR_Y, ICON_SPEAKER0);
else if (requiredSpeakerVolume < 10)
LCD_ICON(BAR_VOLUME_X, BAR_Y, ICON_SPEAKER1);
else if (requiredSpeakerVolume < 20)
LCD_ICON(BAR_VOLUME_X, BAR_Y, ICON_SPEAKER2);
else
LCD_ICON(BAR_VOLUME_X, BAR_Y, ICON_SPEAKER3);
/* RTC time */ /* RTC time */
struct gtm t; struct gtm t;
@@ -253,11 +288,11 @@ void displayTopBar()
lcd_outdezNAtt(BAR_TIME_X+3*FWNUM-1, BAR_Y+1, t.tm_min, LEADING0, 2); lcd_outdezNAtt(BAR_TIME_X+3*FWNUM-1, BAR_Y+1, t.tm_min, LEADING0, 2);
/* The background */ /* The background */
lcd_filled_rect(BAR_X, BAR_Y, 182, 9, SOLID, FILL_WHITE|GREY_DEFAULT); lcd_filled_rect(BAR_X, BAR_Y, BAR_W, BAR_H, SOLID, FILL_WHITE|GREY_DEFAULT);
/* The inside of the Batt gauge */ /* The inside of the Batt gauge */
uint8_t count = 10 * (g_vbat100mV - g_eeGeneral.vBatMin - 90) / (30 + g_eeGeneral.vBatMax - g_eeGeneral.vBatMin); uint8_t count = 10 * (g_vbat100mV - g_eeGeneral.vBatMin - 90) / (30 + g_eeGeneral.vBatMax - g_eeGeneral.vBatMin);
displayTopBarGauge(VBATT_X, count, g_vbat100mV <= g_eeGeneral.vBatWarn); displayTopBarGauge(BAR_BATT_X+FW, count, g_vbat100mV <= g_eeGeneral.vBatWarn);
/* The inside of the RSSI gauge */ /* The inside of the RSSI gauge */
count = min(frskyData.rssi[0].value, frskyData.rssi[1].value) / 10; count = min(frskyData.rssi[0].value, frskyData.rssi[1].value) / 10;
+4
View File
@@ -1242,6 +1242,10 @@ enum AUDIO_SOUNDS {
#include "rtc.h" #include "rtc.h"
#endif #endif
#if defined(CPUARM)
extern uint8_t requiredSpeakerVolume;
#endif
// Re-useable byte array to save having multiple buffers // Re-useable byte array to save having multiple buffers
#define SD_SCREEN_FILE_LENGTH (32) #define SD_SCREEN_FILE_LENGTH (32)
union ReusableBuffer union ReusableBuffer