156 #include "../../c_memory/source/c_memory.h"
157 #include "../../c_com/source/c_com.h"
158 #include "../../c_input/source/c_input.h"
161 extern char *
strptime(
const char *s,
const char *format,
struct tm *tm);
169 #if (HARDWARE != SIMULATION)
171 #include <sys/stat.h>
172 #include <sys/statvfs.h>
173 #include <sys/types.h>
174 #include <sys/sysinfo.h>
183 #include <sys/mman.h>
184 #include <sys/ioctl.h>
186 #include <sys/utsname.h>
188 #include <sys/socket.h>
189 #include <netinet/in.h>
191 #include <arpa/inet.h>
199 #define snprintf _snprintf
206 gUiInstance= _Instance;
217 #ifndef DISABLE_VIRTUAL_BATT_TEMP
255 static int index = 0;
256 static float I_bat_mean = 0;
257 const float sample_period = 0.4;
258 static float T_bat = 0;
259 static float T_elec = 0;
261 static float R_bat_model_old = 0;
263 static float R_bat = 0;
266 const float I_1A = 0.05;
267 const float I_2A = 2.0;
273 static unsigned char has_passed_7v5_flag =
'N';
275 float dT_bat_own = 0.0;
276 float dT_bat_loss_to_elec = 0.0;
277 float dT_bat_gain_from_elec = 0.0;
278 float dT_bat_loss_to_room = 0.0;
280 float dT_elec_own = 0.0;
281 float dT_elec_loss_to_bat = 0.0;
282 float dT_elec_gain_from_bat = 0.0;
283 float dT_elec_loss_to_room = 0.0;
290 I_bat_mean = ((index) * I_bat_mean + I_bat) / (index + 1) ;
301 R_1A = 0.014071 * (V_bat * V_bat * V_bat * V_bat)
302 - 0.335324 * (V_bat * V_bat * V_bat)
303 + 2.933404 * (V_bat * V_bat)
308 R_2A = 0.014420 * (V_bat * V_bat * V_bat * V_bat)
309 - 0.316728 * (V_bat * V_bat * V_bat)
310 + 2.559347 * (V_bat * V_bat)
315 slope_A = (R_1A - R_2A) / (I_1A - I_2A);
318 intercept_b = R_1A - slope_A * R_1A;
321 R_bat_model = slope_A * I_bat_mean + intercept_b;
324 if ((V_bat > 7.5) && (has_passed_7v5_flag ==
'N'))
332 if ((R_bat_model - R_bat_model_old) > 0)
334 R_bat = R_bat + R_bat_model - R_bat_model_old;
338 R_bat = R_bat + (
R_bat_neg_gain * (R_bat_model - R_bat_model_old));
341 has_passed_7v5_flag =
'Y';
345 R_bat_model_old = R_bat_model;
351 printf(
"%c %f %f %f %f %f %f\n", has_passed_7v5_flag, R_1A, R_2A,
352 slope_A, intercept_b, R_bat_model - R_bat_model_old, R_bat);
370 dT_bat_loss_to_elec = 0.0;
381 dT_bat_gain_from_elec = 0.0;
403 dT_elec_loss_to_bat = 0.0;
414 dT_elec_gain_from_bat = 0.0;
425 printf(
"%f %f %f %f %f <> %f %f %f %f %f\n",dT_bat_own, dT_bat_loss_to_elec,
426 dT_bat_gain_from_elec, dT_bat_loss_to_room, T_bat,
427 dT_elec_own, dT_elec_loss_to_bat, dT_elec_gain_from_bat,
428 dT_elec_loss_to_room, T_elec);
435 T_bat = T_bat + dT_bat_own + dT_bat_loss_to_elec
436 + dT_bat_gain_from_elec + dT_bat_loss_to_room;
439 T_elec = T_elec + dT_elec_own + dT_elec_loss_to_bat
440 + dT_elec_gain_from_bat + dT_elec_loss_to_room;
448 #ifdef DEBUG_VIRTUAL_BATT_TEMP
449 static int TempFile = -1;
453 #ifndef DISABLE_VIRTUAL_BATT_TEMP
457 #define CALL_INTERVAL 400 // [mS]
459 #ifdef DEBUG_VIRTUAL_BATT_TEMP
461 void cUiInitTemp(
void)
470 mkdir(
"../prjs/TempTest",DIRPERMISSIONS);
471 chmod(
"../prjs/TempTest",DIRPERMISSIONS);
475 pFile = fopen (
"../prjs/Const/TempConst.rtf",
"r");
480 Str = fgets(Buffer,250,pFile);
484 if ((Buffer[0] !=
'/') && (Buffer[0] !=
'*') && (Buffer[0] !=
' '))
487 if (sscanf(Buffer,
"%f",&Const[Tmp]) != 1)
512 TempFile = open(
"../prjs/TempTest/TempFile.rtf",O_CREAT | O_WRONLY | O_APPEND | O_SYNC,FILEPERMISSIONS);
513 chmod(
"../prjs/TempTest/TempFile.rtf",FILEPERMISSIONS);
514 if (TempFile >= MIN_HANDLE)
518 BufferSize =
snprintf(Buffer,250,
"* TempConst.rtf ************************\r\n");
522 BufferSize =
snprintf(Buffer,250,
"* Build in *****************************\r\n");
524 write(TempFile,Buffer,BufferSize);
526 write(TempFile,Buffer,BufferSize);
528 write(TempFile,Buffer,BufferSize);
530 write(TempFile,Buffer,BufferSize);
532 write(TempFile,Buffer,BufferSize);
534 write(TempFile,Buffer,BufferSize);
536 write(TempFile,Buffer,BufferSize);
538 write(TempFile,Buffer,BufferSize);
540 write(TempFile,Buffer,BufferSize);
542 write(TempFile,Buffer,BufferSize);
544 write(TempFile,Buffer,BufferSize);
546 write(TempFile,Buffer,BufferSize);
547 BufferSize =
snprintf(Buffer,250,
"****************************************\r\n");
548 write(TempFile,Buffer,BufferSize);
555 void cUiExitTemp(
void)
557 if (TempFile >= MIN_HANDLE)
568 IMGDATA DownloadSuccesSound[] = { opINFO,
LC0(GET_VOLUME),
LV0(0),opSOUND,
LC0(PLAY),
LV0(0),
LCS,
'u',
'i',
'/',
'D',
'o',
'w',
'n',
'l',
'o',
'a',
'd',
'S',
'u',
'c',
'c',
'e',
's',0,opSOUND_READY,opOBJECT_END };
582 for (Button = 0;Button <
BUTTONS;Button++)
593 for (Button = 0;Button <
BUTTONS;Button++)
606 if (UiInstance.
UiFile >= MIN_HANDLE)
610 if ((State == LED_GREEN_FLASH) || (State == LED_RED_FLASH) || (State == LED_ORANGE_FLASH))
612 Buffer[0] = LED_ORANGE_FLASH +
'0';
616 if ((State == LED_GREEN_PULSE) || (State == LED_RED_PULSE) || (State == LED_ORANGE_PULSE))
618 Buffer[0] = LED_ORANGE_PULSE +
'0';
622 Buffer[0] = LED_ORANGE +
'0';
628 Buffer[0] = UiInstance.
LedState +
'0';
631 write(UiInstance.
UiFile,Buffer,2);
695 UiInstance.
Tbatt = 0.0;
696 UiInstance.
Vbatt = 9.0;
697 UiInstance.
Ibatt = 0.0;
701 UiInstance.
Ibatt = 0.1;
707 UiInstance.
PowerFile = open(POWER_DEVICE_NAME,O_RDWR);
708 UiInstance.
UiFile = open(UI_DEVICE_NAME,O_RDWR | O_SYNC);
709 UiInstance.
AdcFile = open(ANALOG_DEVICE_NAME,O_RDWR | O_SYNC);
714 if (UiInstance.
UiFile >= MIN_HANDLE)
716 pUiTmp = (UI*)mmap(0,
sizeof(UI), PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, UiInstance.
UiFile, 0);
718 if (pUiTmp == MAP_FAILED)
727 UiInstance.
pUi = pUiTmp;
731 sscanf(&UiInstance.
HwVers[1],
"%f",&Hw);
745 if (UiInstance.
AdcFile >= MIN_HANDLE)
747 pAdcTmp = (ANALOG*)mmap(0,
sizeof(ANALOG), PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, UiInstance.
AdcFile, 0);
749 if (pAdcTmp == MAP_FAILED)
769 if (SPECIALVERS <
'0')
779 snprintf(Buffer,32,
"%s %s",__DATE__,__TIME__);
780 strptime((
const char*)Buffer,(
const char*)
"%B %d %Y %H:%M:%S",(
struct tm*)&tm);
783 pOs = (
struct utsname*)OsBuf;
788 sprintf((
char*)UiInstance.
OsBuild,
"?");
790 Lng = strlen((*pOs).version) - 9;
793 (*pOs).version[Lng++] =
' ';
794 (*pOs).version[Lng++] =
' ';
795 (*pOs).version[Lng++] =
' ';
796 (*pOs).version[Lng++] =
' ';
798 Lng = strlen((*pOs).version);
802 while ((Start < Lng) && (Tmp == 0))
804 if (
strptime((
const char*)&(*pOs).version[Start],(
const char*)
"%B %d %H:%M:%S %Y",(
struct tm*)&tm) !=
NULL)
817 Sid = socket(AF_INET,SOCK_DGRAM,0);
818 Sifr.ifr_addr.sa_family = AF_INET;
819 strncpy(Sifr.ifr_name,
"eth0",
IFNAMSIZ - 1);
820 if (ioctl(Sid,SIOCGIFADDR,&Sifr) >= 0)
839 if (Buffer[0] ==
'1')
851 #ifdef DEBUG_VIRTUAL_BATT_TEMP
861 RESULT Result = FAIL;
880 RESULT Result = FAIL;
900 RESULT Result = FAIL;
902 #ifdef DEBUG_VIRTUAL_BATT_TEMP
908 if (UiInstance.
AdcFile >= MIN_HANDLE)
910 munmap(UiInstance.
pAnalog,
sizeof(ANALOG));
914 if (UiInstance.
UiFile >= MIN_HANDLE)
916 munmap(UiInstance.
pUi,
sizeof(UI));
935 for (Button = 0;Button <
BUTTONS;Button++)
940 if ((*UiInstance.
pUi).Pressed[Button])
990 if ((Button != 1) && (Button != 5))
1003 if (UiInstance.
ButtonTimer[Button] >= LONG_PRESS_TIME)
1026 UiInstance.
ButtonState[Button] &= ~BUTTON_PRESSED;
1035 #ifndef LEGO_SIMULATION
1095 Result = UiInstance.
Escape;
1118 if ((Char >=
'0') && (Char <=
'9'))
1120 Tmp = (
UBYTE)(Char -
'0');
1126 if ((Char >=
'a') && (Char <=
'f'))
1128 Tmp = (
UBYTE)(Char -
'a') + 10;
1163 #define REAL_ANY_BUTTON 6
1164 #define REAL_NO_BUTTON 7
1185 if ((Mapped >= 0) && (Mapped < BUTTONTYPES))
1187 Real = MappedToReal[Mapped];
1219 for (Button = 0;Button <
BUTTONS;Button++)
1226 for (Button = 0;Button <
BUTTONS;Button++)
1253 for (Button = 0;Button <
BUTTONS;Button++)
1284 for (Button = 0;Button <
BUTTONS;Button++)
1297 for (Button = 0;Button <
BUTTONS;Button++)
1322 UiInstance.
ButtonState[Button] &= ~BUTTON_ACTIVATED;
1330 for (Button = 0;Button <
BUTTONS;Button++)
1334 UiInstance.
ButtonState[Button] &= ~BUTTON_ACTIVATED;
1344 for (Button = 0;Button <
BUTTONS;Button++)
1348 UiInstance.
ButtonState[Button] &= ~BUTTON_ACTIVATED;
1357 UiInstance.
Click = 1;
1382 for (Button = 0;Button <
BUTTONS;Button++)
1396 for (Button = 0;Button <
BUTTONS;Button++)
1429 for (Button = 0;Button <
BUTTONS;Button++)
1442 for (Button = 0;Button <
BUTTONS;Button++)
1467 UiInstance.
ButtonState[Button] &= ~BUTTON_LONGPRESS;
1475 for (Button = 0;Button <
BUTTONS;Button++)
1479 UiInstance.
ButtonState[Button] &= ~BUTTON_LONGPRESS;
1489 for (Button = 0;Button <
BUTTONS;Button++)
1493 UiInstance.
ButtonState[Button] &= ~BUTTON_LONGPRESS;
1502 UiInstance.
Click = 1;
1572 return ((X + 7) & ~7);
1576 #define SHUNT_IN 0.11 // [Ohm]
1577 #define AMP_CIN 22.0 // [Times]
1579 #define EP2_SHUNT_IN 0.05 // [Ohm]
1580 #define EP2_AMP_CIN 15.0 // [Times]
1582 #define SHUNT_OUT 0.055 // [Ohm]
1583 #define AMP_COUT 19.0 // [Times]
1585 #define VCE 0.05 // [V]
1586 #define AMP_VIN 0.5 // [Times]
1592 #define CNT_V(C) (((DATAF)C * (DATAF)ADC_REF) / ((DATAF)ADC_RES * (DATAF)1000.0))
1648 #ifdef DEBUG_TEMP_SHUTDOWN
1650 UiInstance.
Vbatt = 7.0;
1651 UiInstance.
Ibatt = 5.0;
1702 #define TOP_BATT_ICONS 5
1713 #define TOP_BT_ICONS 4
1723 #define TOP_WIFI_ICONS 4
1728 SICON_WIFI_CONNECTED,
1729 SICON_WIFI_CONNECTED,
1740 DATA8 Name[NAME_LENGTH + 1];
1743 static DATA16 Counter = 0;
1746 #ifdef DEBUG_VIRTUAL_BATT_TEMP
1749 #ifdef ENABLE_MEMORY_TEST
1761 sprintf(Buffer,
"%d",Counter);
1776 if (UiInstance.
BtOn != TmpStatus)
1778 UiInstance.
BtOn = TmpStatus;
1794 if (UiInstance.
WiFiOn != TmpStatus)
1796 UiInstance.
WiFiOn = TmpStatus;
1799 #ifdef DEBUG_VIRTUAL_BATT_TEMP
1809 X2 -= strlen((
char*)Name);
1814 #ifdef ENABLE_PERFORMANCE_TEST
1817 X2 = (X2 * 40) / 1000;
1825 #ifdef ENABLE_LOAD_TEST
1828 X2 = (X2 * 40) / (
DATA16)(LOAD_SHUTDOWN_HIGH * 1000.0);
1836 #ifdef ENABLE_MEMORY_TEST
1850 #ifdef ENABLE_STATUS_TEST
1853 for (V = 0;V < 7;V++)
1877 #ifdef DEBUG_BACK_BLOCKED
1898 #ifdef DEBUG_RECHARGEABLE
1899 if (UiInstance.
Accu == 0)
1914 UiInstance.
Font = NORMAL_FONT;
1920 #include "mindstorms.xbm"
1921 #include "Ani1x.xbm"
1922 #include "Ani2x.xbm"
1923 #include "Ani3x.xbm"
1924 #include "Ani4x.xbm"
1925 #include "Ani5x.xbm"
1926 #include "Ani6x.xbm"
1929 #include "PCApp.xbm"
2083 #ifndef DISABLE_LOW_VOLTAGE
2170 #ifdef ENABLE_HIGH_CURRENT
2224 void cUiCheckPower(
UWORD Time)
2233 if (I > LOAD_BREAK_EVEN)
2235 Slope = LOAD_SLOPE_UP;
2239 Slope = LOAD_SLOPE_DOWN;
2242 UiInstance.
Iintegrated += (I - LOAD_BREAK_EVEN) * (Slope * (
DATAF)Time / 1000.0);
2253 if ((UiInstance.
Iintegrated >= LOAD_SHUTDOWN_HIGH) || (I >= LOAD_SHUTDOWN_FAIL))
2357 #ifndef DISABLE_VIRTUAL_BATT_TEMP
2382 #ifdef DEBUG_TEMP_SHUTDOWN
2383 UiInstance.
Tbatt += 35.0;
2385 #ifdef DEBUG_VIRTUAL_BATT_TEMP
2389 if (TempFile >= MIN_HANDLE)
2392 write(TempFile,Buffer,BufferSize);
2397 if (UiInstance.
Tbatt >= TEMP_SHUTDOWN_WARNING)
2407 if (UiInstance.
Tbatt >= TEMP_SHUTDOWN_FAIL)
2415 #ifndef DISABLE_LOW_MEMORY
2425 if (Free > LOW_MEMORY)
2456 if (UiInstance.
SleepTimer >= (Timeout * 60000L))
2475 #ifdef MAX_FRAMES_PER_SEC
2476 UiInstance.DisplayTimer += (
ULONG)Time;
2477 if (UiInstance.DisplayTimer >= (1000 / MAX_FRAMES_PER_SEC))
2479 UiInstance.AllowUpdate = 1;
2492 if (!UiInstance.
Event)
2502 #ifdef ENABLE_HIGH_CURRENT
2508 #ifndef DISABLE_VIRTUAL_BATT_TEMP
2511 if (!UiInstance.
Accu)
2531 #ifndef DISABLE_LOW_MEMORY
2550 #ifndef DISABLE_LOW_VOLTAGE
2727 UiInstance.
Warning &= ~WARNING_DSPSTAT;
2753 [FILETYPE_UNKNOWN] = ICON_FOLDER,
2754 [TYPE_FOLDER] = ICON_FOLDER,
2755 [TYPE_SOUND] = ICON_SOUND,
2756 [TYPE_BYTECODE] = ICON_RUN,
2757 [TYPE_GRAPHICS] = ICON_IMAGE,
2758 [TYPE_DATALOG] = ICON_OBD,
2759 [TYPE_PROGRAM] = ICON_OBP,
2760 [TYPE_TEXT] = ICON_TEXT
2765 RESULT Result = BUSY;
2784 (*pQ).ScreenStartY = Y;
2785 (*pQ).ScreenWidth = POP3_width;
2786 (*pQ).ScreenHeight = POP3_height;
2787 (*pQ).IconStartY = (*pQ).ScreenStartY + 10;
2790 (*pQ).IconSpaceX = (*pQ).IconWidth;
2792 (*pQ).YesNoStartX = (*pQ).ScreenStartX + ((*pQ).ScreenWidth / 2);
2793 (*pQ).YesNoStartX -= ((*pQ).IconWidth + 8) / 2;
2794 (*pQ).YesNoStartX =
cUiAlignX((*pQ).YesNoStartX);
2795 (*pQ).YesNoStartY = (*pQ).ScreenStartY + 40;
2797 (*pQ).LineStartX = (*pQ).ScreenStartX + 5;
2798 (*pQ).LineStartY = (*pQ).ScreenStartY + 39;
2799 (*pQ).LineEndX = (*pQ).LineStartX + 134;
2802 (*pQ).NoOfIcons = 0;
2803 if (Icon1 > ICON_NONE)
2807 if (Icon2 > ICON_NONE)
2811 if (Icon3 > ICON_NONE)
2817 (*pQ).TextLines = 0;
2820 (*pQ).IconStartX = (*pQ).ScreenStartX + 8;
2821 (*pQ).IconStartX =
cUiAlignX((*pQ).IconStartX);
2823 AvailableX = (*pQ).ScreenWidth;
2824 AvailableX -= (((*pQ).IconStartX - (*pQ).ScreenStartX)) * 2;
2826 AvailableX -= (*pQ).NoOfIcons * (*pQ).IconSpaceX;
2829 (*pQ).NoOfChars = strlen((
char*)pText);
2832 (*pQ).Font = SMALL_FONT;
2834 UsedX = (*pQ).FontWidth * (*pQ).NoOfChars;
2838 if (UsedX <= AvailableX)
2841 if ((AvailableX - UsedX) >= 32)
2843 (*pQ).IconStartX += 32;
2850 (*pQ).TextStartX = (*pQ).IconStartX + ((*pQ).NoOfIcons * (*pQ).IconSpaceX) ;
2851 (*pQ).TextStartY = (*pQ).ScreenStartY + 18;
2857 (*pQ).Font = TINY_FONT;
2859 UsedX = (*pQ).FontWidth * (*pQ).NoOfChars;
2860 AvailableX -= (*pQ).FontWidth;
2868 while ((pText[CharIn]) && (CharOut <
MAX_NOTIFY_LINE_CHARS) && (UsedX < (AvailableX - (*pQ).FontWidth)))
2870 Character = pText[CharIn];
2871 if (Character ==
'_')
2875 (*pQ).TextLine[Line][CharOut] = Character;
2878 UsedX += (*pQ).FontWidth;
2880 while ((CharOut > 8) && (pText[CharIn] !=
' ') && (pText[CharIn] !=
'_') && (pText[CharIn] != 0))
2885 if (pText[CharIn] != 0)
2889 (*pQ).TextLine[Line][CharOut] = 0;
2893 (*pQ).TextLines = Line;
2895 (*pQ).TextStartX = (*pQ).IconStartX + ((*pQ).NoOfIcons * (*pQ).IconSpaceX) + (*pQ).FontWidth ;
2899 AvailableY = (*pQ).LineStartY - ((*pQ).ScreenStartY + 5);
2900 UsedY = (*pQ).TextLines * (*pQ).TextSpaceY;
2902 while (UsedY > AvailableY)
2905 UsedY = (*pQ).TextLines * (*pQ).TextSpaceY;
2907 Y2 = (AvailableY - UsedY) / 2;
2909 (*pQ).TextStartY = (*pQ).ScreenStartY + Y2 + 5;
2915 (*pQ).IconStartX = (*pQ).ScreenStartX + ((*pQ).ScreenWidth / 2);
2916 (*pQ).IconStartX -= ((*pQ).IconWidth + 8) / 2;
2917 (*pQ).IconStartX -= ((*pQ).NoOfIcons / 2) * (*pQ).IconWidth;
2918 (*pQ).IconStartX =
cUiAlignX((*pQ).IconStartX);
2919 (*pQ).TextStartY = (*pQ).ScreenStartY + 8;
2922 (*pQ).NeedUpdate = 1;
2926 if ((*pQ).NeedUpdate)
2929 (*pQ).NeedUpdate = 0;
2931 dLcdDrawPicture((*UiInstance.
pLcd).Lcd,Color,(*pQ).ScreenStartX,(*pQ).ScreenStartY,POP3_width,POP3_height,(
UBYTE*)POP3_bits);
2933 X2 = (*pQ).IconStartX;
2935 if (Icon1 > ICON_NONE)
2937 dLcdDrawIcon((*UiInstance.
pLcd).Lcd,Color,X2,(*pQ).IconStartY,LARGE_ICON,Icon1);
2938 X2 += (*pQ).IconSpaceX;
2940 if (Icon2 > ICON_NONE)
2942 dLcdDrawIcon((*UiInstance.
pLcd).Lcd,Color,X2,(*pQ).IconStartY,LARGE_ICON,Icon2);
2943 X2 += (*pQ).IconSpaceX;
2945 if (Icon3 > ICON_NONE)
2947 dLcdDrawIcon((*UiInstance.
pLcd).Lcd,Color,X2,(*pQ).IconStartY,LARGE_ICON,Icon3);
2948 X2 += (*pQ).IconSpaceX;
2952 Y2 = (*pQ).TextStartY;
2953 while (Line < (*pQ).TextLines)
2955 dLcdDrawText((*UiInstance.
pLcd).Lcd,Color,(*pQ).TextStartX,Y2,(*pQ).Font,(*pQ).TextLine[Line]);
2956 Y2 += (*pQ).TextSpaceY;
2960 dLcdDrawLine((*UiInstance.
pLcd).Lcd,Color,(*pQ).LineStartX,(*pQ).LineStartY,(*pQ).LineEndX,(*pQ).LineStartY);
2962 dLcdDrawIcon((*UiInstance.
pLcd).Lcd,Color,(*pQ).YesNoStartX,(*pQ).YesNoStartY,LARGE_ICON,YES_SEL);
2981 RESULT Result = BUSY;
2990 (*pQ).NeedUpdate = 1;
2997 (*pQ).NeedUpdate = 0;
3002 (*pQ).NeedUpdate = 0;
3009 (*pQ).ScreenStartX = X;
3010 (*pQ).ScreenStartY = Y;
3014 (*pQ).NoOfIcons = 0;
3015 if (Icon1 > ICON_NONE)
3019 if (Icon2 > ICON_NONE)
3023 (*pQ).Default = *pAnswer;
3025 (*pQ).NeedUpdate = 1;
3029 if ((*pQ).NeedUpdate)
3032 (*pQ).NeedUpdate = 0;
3034 dLcdDrawPicture((*UiInstance.
pLcd).Lcd,Color,(*pQ).ScreenStartX,(*pQ).ScreenStartY,POP3_width,POP3_height,(
UBYTE*)POP3_bits);
3035 (*pQ).ScreenWidth = POP3_width;
3036 (*pQ).ScreenHeight = POP3_height;
3038 (*pQ).IconStartX = (*pQ).ScreenStartX + ((*pQ).ScreenWidth / 2);
3039 if ((*pQ).NoOfIcons > 1)
3041 (*pQ).IconStartX -= (*pQ).IconWidth;
3045 (*pQ).IconStartX -= (*pQ).IconWidth / 2;
3047 (*pQ).IconStartX =
cUiAlignX((*pQ).IconStartX);
3048 (*pQ).IconSpaceX = (*pQ).IconWidth;
3049 (*pQ).IconStartY = (*pQ).ScreenStartY + 10;
3051 (*pQ).YesNoStartX = (*pQ).ScreenStartX + ((*pQ).ScreenWidth / 2);
3052 (*pQ).YesNoStartX -= 8;
3053 (*pQ).YesNoStartX -= (*pQ).IconWidth;
3054 (*pQ).YesNoStartX =
cUiAlignX((*pQ).YesNoStartX);
3055 (*pQ).YesNoSpaceX = (*pQ).IconWidth + 16;
3056 (*pQ).YesNoStartY = (*pQ).ScreenStartY + 40;
3058 (*pQ).LineStartX = (*pQ).ScreenStartX + 5;
3059 (*pQ).LineStartY = (*pQ).ScreenStartY + 39;
3060 (*pQ).LineEndX = (*pQ).LineStartX + 134;
3062 switch ((*pQ).NoOfIcons)
3066 dLcdDrawIcon((*UiInstance.
pLcd).Lcd,Color,(*pQ).IconStartX,(*pQ).IconStartY,LARGE_ICON,Icon1);
3072 dLcdDrawIcon((*UiInstance.
pLcd).Lcd,Color,(*pQ).IconStartX,(*pQ).IconStartY,LARGE_ICON,Icon1);
3073 dLcdDrawIcon((*UiInstance.
pLcd).Lcd,Color,(*pQ).IconStartX + (*pQ).IconSpaceX,(*pQ).IconStartY,LARGE_ICON,Icon2);
3081 dLcdDrawIcon((*UiInstance.
pLcd).Lcd,Color,(*pQ).YesNoStartX,(*pQ).YesNoStartY,LARGE_ICON,NO_SEL);
3082 dLcdDrawIcon((*UiInstance.
pLcd).Lcd,Color,(*pQ).YesNoStartX + (*pQ).YesNoSpaceX,(*pQ).YesNoStartY,LARGE_ICON,YES_NOTSEL);
3086 dLcdDrawIcon((*UiInstance.
pLcd).Lcd,Color,(*pQ).YesNoStartX,(*pQ).YesNoStartY,LARGE_ICON,NO_NOTSEL);
3087 dLcdDrawIcon((*UiInstance.
pLcd).Lcd,Color,(*pQ).YesNoStartX + (*pQ).YesNoSpaceX,(*pQ).YesNoStartY,LARGE_ICON,YES_SEL);
3090 dLcdDrawLine((*UiInstance.
pLcd).Lcd,Color,(*pQ).LineStartX,(*pQ).LineStartY,(*pQ).LineEndX,(*pQ).LineStartY);
3115 RESULT Result = BUSY;
3129 (*pQ).ScreenStartY = Y;
3130 (*pQ).ScreenWidth = POP2_width;
3131 (*pQ).ScreenHeight = POP2_height;
3135 (*pQ).Icons = *pIcons;
3136 (*pQ).NoOfIcons = 0;
3139 TmpIcons = (*pQ).Icons;
3149 if ((*pQ).NoOfIcons)
3151 (*pQ).IconStartY = (*pQ).ScreenStartY + (((*pQ).ScreenHeight - (*pQ).IconHeight) / 2);
3153 (*pQ).IconSpaceX = (((*pQ).ScreenWidth - ((*pQ).IconWidth * (*pQ).NoOfIcons)) / (*pQ).NoOfIcons) + (*pQ).IconWidth;
3154 (*pQ).IconSpaceX = (*pQ).IconSpaceX & ~7;
3156 Tmp = (*pQ).IconSpaceX * (*pQ).NoOfIcons - ((*pQ).IconSpaceX - (*pQ).IconWidth);
3158 (*pQ).IconStartX = (*pQ).ScreenStartX + (((*pQ).ScreenWidth - Tmp) / 2);
3159 (*pQ).IconStartX = ((*pQ).IconStartX + 7) & ~7;
3161 (*pQ).SelectStartX = (*pQ).IconStartX - 1;
3162 (*pQ).SelectStartY = (*pQ).IconStartY - 1;
3163 (*pQ).SelectWidth = (*pQ).IconWidth + 2;
3164 (*pQ).SelectHeight = (*pQ).IconHeight + 2;
3165 (*pQ).SelectSpaceX = (*pQ).IconSpaceX;
3168 printf(
"Shown icons %d -> 0x%08X\r\n",(*pQ).NoOfIcons,(*pQ).Icons);
3171 (*pQ).NeedUpdate = 1;
3174 if ((*pQ).NoOfIcons)
3180 (*pQ).PointerX += Tmp;
3182 (*pQ).NeedUpdate = 1;
3184 if ((*pQ).PointerX < 0)
3187 (*pQ).NeedUpdate = 0;
3189 if ((*pQ).PointerX >= (*pQ).NoOfIcons)
3191 (*pQ).PointerX = (*pQ).NoOfIcons - 1;
3192 (*pQ).NeedUpdate = 0;
3197 if ((*pQ).NeedUpdate)
3200 (*pQ).NeedUpdate = 0;
3202 dLcdDrawPicture((*UiInstance.
pLcd).Lcd,Color,(*pQ).ScreenStartX,(*pQ).ScreenStartY,POP2_width,POP2_height,(
UBYTE*)POP2_bits);
3203 (*pQ).ScreenWidth = POP2_width;
3204 (*pQ).ScreenHeight = POP2_height;
3209 TmpIcons = (*pQ).Icons;
3210 while (Loop < (*pQ).NoOfIcons)
3212 while (!(TmpIcons & 1))
3217 dLcdDrawIcon((*UiInstance.
pLcd).Lcd,Color,(*pQ).IconStartX + (*pQ).IconSpaceX * Loop,(*pQ).IconStartY,LARGE_ICON,Icon);
3224 dLcdInverseRect((*UiInstance.
pLcd).Lcd,(*pQ).SelectStartX + (*pQ).SelectSpaceX * (*pQ).PointerX,(*pQ).SelectStartY,(*pQ).SelectWidth,(*pQ).SelectHeight);
3232 if ((*pQ).NoOfIcons)
3235 TmpIcons = (*pQ).Icons;
3236 Loop = (*pQ).PointerX + 1;
3240 if (TmpIcons & Mask)
3246 while (Loop && Mask);
3258 printf(
"Selecting icon %d -> 0x%08X\r\n",(*pQ).PointerX,*pIcons);
3273 #include "keyboardc.xbm"
3274 #include "keyboards.xbm"
3275 #include "keyboardn.xbm"
3277 #define MAX_KEYB_DEEPT 3
3278 #define MAX_KEYB_WIDTH 12
3279 #define MAX_KEYB_HEIGHT 4
3293 DATA8 SelectedChar = 0;
3311 {
'Q',
'W',
'E',
'R',
'T',
'Y',
'U',
'I',
'O',
'P', 0x08,0x00 },
3312 { 0x03,
'A',
'S',
'D',
'F',
'G',
'H',
'J',
'K',
'L', 0x0D,0x00 },
3313 { 0x01,
'Z',
'X',
'C',
'V',
'B',
'N',
'M',0x0D,0x0D,0x0D,0x00 },
3314 {
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ', 0x0D,0x00 }
3317 {
'q',
'w',
'e',
'r',
't',
'y',
'u',
'i',
'o',
'p', 0x08,0x00 },
3318 { 0x02,
'a',
's',
'd',
'f',
'g',
'h',
'j',
'k',
'l', 0x0D,0x00 },
3319 { 0x01,
'z',
'x',
'c',
'v',
'b',
'n',
'm',0x0D,0x0D,0x0D,0x00 },
3320 {
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ', 0x0D,0x00 }
3323 {
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'0', 0x08,0x00 },
3324 { 0x04,
'+',
'-',
'=',
'<',
'>',
'/',
'\\',
'*',
':', 0x0D,0x00 },
3325 { 0x04,
'(',
')',
'_',
'.',
'@',
'!',
'?',0x0D,0x0D,0x0D,0x00 },
3326 {
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ', 0x0D,0x00 }
3336 (*pK).ScreenStartX = X;
3337 (*pK).ScreenStartY = Y;
3339 if ((Icon >= 0) && (Icon < N_ICON_NOS))
3341 (*pK).IconStartX =
cUiAlignX((*pK).ScreenStartX + 7);
3342 (*pK).IconStartY = (*pK).ScreenStartY + 4;
3347 (*pK).TextStartX =
cUiAlignX((*pK).ScreenStartX + 9);
3349 (*pK).TextStartY = (*pK).ScreenStartY + 7;
3350 (*pK).StringStartX = (*pK).ScreenStartX + 8;
3351 (*pK).StringStartY = (*pK).ScreenStartY + 22;
3352 (*pK).KeybStartX = (*pK).ScreenStartX + 13;
3353 (*pK).KeybStartY = (*pK).ScreenStartY + 40;
3354 (*pK).KeybSpaceX = 11;
3355 (*pK).KeybSpaceY = 14;
3356 (*pK).KeybHeight = 13;
3357 (*pK).KeybWidth = 9;
3359 (*pK).PointerX = 10;
3361 (*pK).NeedUpdate = 1;
3364 Width = strlen((
char*)KeyboardLayout[(*pK).Layout][(*pK).PointerY]) - 1;
3368 (*pK).PointerX += Inc;
3369 if ((*pK).PointerX < 0)
3373 if ((*pK).PointerX > Width)
3375 (*pK).PointerX = Width;
3378 (*pK).PointerY += Inc;
3379 if ((*pK).PointerY < 0)
3383 if ((*pK).PointerY > Height)
3385 (*pK).PointerY = Height;
3389 TmpChar = KeyboardLayout[(*pK).Layout][(*pK).PointerY][(*pK).PointerX];
3393 SelectedChar = 0x0D;
3398 SelectedChar = TmpChar;
3400 switch (SelectedChar)
3428 Tmp = (
DATA16)strlen((
char*)pAnswer);
3446 Tmp = (
DATA16)strlen((
char*)pAnswer);
3447 pAnswer[Tmp] = SelectedChar;
3460 TmpChar = KeyboardLayout[(*pK).Layout][(*pK).PointerY][(*pK).PointerX];
3462 (*pK).NeedUpdate = 1;
3465 if (((*pK).OldX != (*pK).PointerX) || ((*pK).OldY != (*pK).PointerY))
3467 (*pK).OldX = (*pK).PointerX;
3468 (*pK).OldY = (*pK).PointerY;
3469 (*pK).NeedUpdate = 1;
3472 if ((*pK).NeedUpdate)
3475 (*pK).NeedUpdate = 0;
3477 switch ((*pK).Layout)
3481 dLcdDrawPicture((*UiInstance.
pLcd).Lcd,Color,(*pK).ScreenStartX,(*pK).ScreenStartY,keyboardc_width,keyboardc_height,(
UBYTE*)keyboardc_bits);
3487 dLcdDrawPicture((*UiInstance.
pLcd).Lcd,Color,(*pK).ScreenStartX,(*pK).ScreenStartY,keyboards_width,keyboards_height,(
UBYTE*)keyboards_bits);
3493 dLcdDrawPicture((*UiInstance.
pLcd).Lcd,Color,(*pK).ScreenStartX,(*pK).ScreenStartY,keyboardn_width,keyboardn_height,(
UBYTE*)keyboardn_bits);
3498 if ((Icon >= 0) && (Icon < N_ICON_NOS))
3500 dLcdDrawIcon((*UiInstance.
pLcd).Lcd,Color,(*pK).IconStartX,(*pK).IconStartY,NORMAL_ICON,Icon);
3504 dLcdDrawText((*UiInstance.
pLcd).Lcd,Color,(*pK).TextStartX,(*pK).TextStartY,SMALL_FONT,pText);
3509 X3 = strlen((
char*)pAnswer);
3515 dLcdDrawText((*UiInstance.
pLcd).Lcd,Color,(*pK).StringStartX,(*pK).StringStartY,NORMAL_FONT,&pAnswer[X4]);
3516 dLcdDrawChar((*UiInstance.
pLcd).Lcd,Color,(*pK).StringStartX + (X3 - X4) * 8,(*pK).StringStartY,NORMAL_FONT,
'_');
3520 SX = (*pK).KeybStartX + (*pK).PointerX * (*pK).KeybSpaceX;
3521 SY = (*pK).KeybStartY + (*pK).PointerY * (*pK).KeybSpaceY;
3535 dLcdInverseRect((*UiInstance.
pLcd).Lcd,SX - 8,(*pK).KeybStartY + 1 * (*pK).KeybSpaceY,(*pK).KeybWidth + 8,(*pK).KeybHeight * 2 + 1);
3547 SX = (*pK).KeybStartX + 112;
3548 SY = (*pK).KeybStartY + 1 * (*pK).KeybSpaceY;
3550 SX = (*pK).KeybStartX + 103;
3551 SY = (*pK).KeybStartY + 1 + 2 * (*pK).KeybSpaceY;
3552 dLcdInverseRect((*UiInstance.
pLcd).Lcd,SX,SY,(*pK).KeybWidth + 14,(*pK).KeybSpaceY * 2 - 4);
3558 dLcdInverseRect((*UiInstance.
pLcd).Lcd,(*pK).KeybStartX + 11,SY + 1,(*pK).KeybWidth + 68,(*pK).KeybHeight - 3);
3573 return (SelectedChar);
3603 KnobHeight = Y1 / Items;
3624 if ((Items > 1) && (Act > 0))
3626 Tmp += ((Y1 - KnobHeight) * (Act - 1)) / (Items - 1);
3694 RESULT Result = BUSY;
3754 if (Type != BROWSE_FILES)
3759 printf(
"Browser interrupted\r\n");
3764 if ((*pType == TYPE_REFRESH_BROWSER))
3769 if ((*pType == TYPE_RESTART_BROWSER))
3784 printf(
"Restarting browser\r\n");
3788 if (((*pB).PrgId == 0) && ((*pB).ObjId == 0))
3793 (*pB).ScreenStartX = X;
3794 (*pB).ScreenStartY = Y;
3795 (*pB).ScreenWidth = X1;
3796 (*pB).ScreenHeight = Y1;
3799 (*pB).LineSpace = 5;
3801 (*pB).LineHeight = (*pB).IconHeight + (*pB).LineSpace;
3802 (*pB).Lines = ((*pB).ScreenHeight / (*pB).LineHeight);
3808 (*pB).Chars = (((*pB).ScreenWidth - (*pB).IconWidth) / (*pB).CharWidth);
3811 (*pB).IconStartX =
cUiAlignX((*pB).ScreenStartX);
3812 (*pB).IconStartY = (*pB).ScreenStartY + (*pB).LineSpace / 2;
3815 (*pB).TextStartX =
cUiAlignX((*pB).ScreenStartX + (*pB).IconWidth);
3816 (*pB).TextStartY = (*pB).ScreenStartY + ((*pB).LineHeight - (*pB).CharHeight) / 2;
3819 (*pB).SelectStartX = (*pB).ScreenStartX + 1;
3820 (*pB).SelectWidth = (*pB).ScreenWidth - ((*pB).CharWidth + 5);
3821 (*pB).SelectStartY = (*pB).IconStartY - 1;
3822 (*pB).SelectHeight = (*pB).IconHeight + 2;
3825 (*pB).ScrollWidth = 6;
3826 (*pB).NobHeight = 9;
3827 (*pB).ScrollStartX = (*pB).ScreenStartX + (*pB).ScreenWidth - (*pB).ScrollWidth;
3828 (*pB).ScrollStartY = (*pB).ScreenStartY + 1;
3829 (*pB).ScrollHeight = (*pB).ScreenHeight - 2;
3830 (*pB).ScrollSpan = (*pB).ScrollHeight - (*pB).NobHeight;
3832 strncpy((
char*)(*pB).TopFolder,(
char*)pAnswer,MAX_FILENAME_SIZE);
3834 (*pB).PrgId = PrgId;
3835 (*pB).ObjId = ObjId;
3839 (*pB).OpenFolder = 0;
3841 (*pB).ItemStart = 1;
3842 (*pB).ItemPointer = 1;
3843 (*pB).NeedUpdate = 1;
3847 if (((*pB).PrgId == PrgId) && ((*pB).ObjId == ObjId))
3856 printf(
"Refreshing browser\r\n");
3868 (*pB).OpenFolder = 0;
3874 case BROWSE_FOLDERS :
3875 case BROWSE_FOLDS_FILES :
3880 printf(
"\r\n%d %d Opening browser in %s\r\n",PrgId,ObjId,(
char*)(*pB).TopFolder);
3883 if ((*pB).OpenFolder)
3885 cMemoryGetItem((*pB).PrgId,(*pB).hFolders,(*pB).OpenFolder,FOLDERNAME_SIZE + SUBFOLDERNAME_SIZE,(*pB).SubFolder,&TmpType);
3887 printf(
"Open folder %3d (%s)\r\n",(*pB).OpenFolder,(*pB).SubFolder);
3891 Item = (*pB).ItemPointer;
3892 cMemoryGetItemName((*pB).PrgId,(*pB).hFolders,Item,MAX_FILENAME_SIZE,(*pB).Filename,pType,&Priority);
3893 Result =
cMemoryGetItem((*pB).PrgId,(*pB).hFolders,Item,FOLDERNAME_SIZE + SUBFOLDERNAME_SIZE,(*pB).FullPath,pType);
3894 *pType = TYPE_SDCARD;
3896 snprintf((
char*)pAnswer,Lng,
"%s",(
char*)(*pB).FullPath);
3902 Item = (*pB).ItemPointer;
3903 cMemoryGetItemName((*pB).PrgId,(*pB).hFolders,Item,MAX_FILENAME_SIZE,(*pB).Filename,pType,&Priority);
3904 Result =
cMemoryGetItem((*pB).PrgId,(*pB).hFolders,Item,FOLDERNAME_SIZE + SUBFOLDERNAME_SIZE,(*pB).FullPath,pType);
3905 *pType = TYPE_USBSTICK;
3907 snprintf((
char*)pAnswer,Lng,
"%s",(
char*)(*pB).FullPath);
3911 Result =
cMemoryOpenFolder(PrgId,FILETYPE_UNKNOWN,(*pB).SubFolder,&(*pB).hFiles);
3921 printf(
"\r\n%d %d Open error\r\n",PrgId,ObjId);
3936 if (
cMemoryOpenFolder(PrgId,FILETYPE_UNKNOWN,(*pB).TopFolder,&(*pB).hFiles) == OK)
3939 printf(
"\r\n%d %d Opening browser in %s\r\n",PrgId,ObjId,(
char*)(*pB).TopFolder);
3946 printf(
"\r\n%d %d Open error\r\n",PrgId,ObjId);
3957 #ifndef DISABLE_SDCARD_SUPPORT
3968 #ifndef DISABLE_USBSTICK_SUPPORT
3982 case BROWSE_FOLDERS :
3983 case BROWSE_FOLDS_FILES :
3989 if (((*pB).OpenFolder) && (TmpResult == OK))
4010 if (((*pB).OpenFolder != 0) && ((*pB).OpenFolder == (*pB).ItemPointer))
4016 printf(
"Close folder %3d\r\n",(*pB).OpenFolder);
4020 if ((*pB).ItemPointer > (*pB).OpenFolder)
4022 (*pB).ItemPointer -= (*pB).Files;
4024 (*pB).OpenFolder = 0;
4029 #ifndef DISABLE_SDCARD_SUPPORT
4030 if ((*pB).Sdcard == 1)
4032 if ((*pB).OpenFolder == 0)
4038 printf(
"Collapse sdcard\r\n");
4050 strcpy((
char*)pAnswer,vmPRJS_DIR);
4052 (*pB).SubFolder[0] = 0;
4057 #ifndef DISABLE_USBSTICK_SUPPORT
4058 if ((*pB).Usbstick == 1)
4060 if ((*pB).OpenFolder == 0)
4066 printf(
"Collapse usbstick\r\n");
4078 strcpy((
char*)pAnswer,vmPRJS_DIR);
4080 (*pB).SubFolder[0] = 0;
4085 if ((*pB).OldFiles != ((*pB).Files + (*pB).Folders))
4087 (*pB).OldFiles = ((*pB).Files + (*pB).Folders);
4088 (*pB).NeedUpdate = 1;
4094 if ((*pB).OpenFolder)
4096 if (((*pB).ItemPointer > (*pB).OpenFolder) && ((*pB).ItemPointer <= ((*pB).OpenFolder + (*pB).Files)))
4099 Item = (*pB).ItemPointer - (*pB).OpenFolder;
4100 Result =
cMemoryGetItem((*pB).PrgId,(*pB).hFiles,Item,Lng,(*pB).FullPath,pType);
4102 snprintf((
char*)pAnswer,Lng,
"%s",(
char*)(*pB).FullPath);
4106 printf(
"Select file %3d\r\n",Item);
4112 if ((*pB).OpenFolder == (*pB).ItemPointer)
4115 Item = (*pB).OpenFolder;
4116 Result =
cMemoryGetItem((*pB).PrgId,(*pB).hFolders,Item,Lng,pAnswer,pType);
4118 printf(
"Select folder %3d\r\n",Item);
4125 printf(
"Close folder %3d\r\n",(*pB).OpenFolder);
4129 if ((*pB).ItemPointer > (*pB).OpenFolder)
4131 (*pB).ItemPointer -= (*pB).Files;
4133 (*pB).OpenFolder = 0;
4138 if ((*pB).OpenFolder == 0)
4143 case BROWSE_FOLDERS :
4146 Item = (*pB).ItemPointer;
4147 cMemoryGetItemName((*pB).PrgId,(*pB).hFolders,Item,MAX_FILENAME_SIZE,(*pB).Filename,pType,&Priority);
4148 Result =
cMemoryGetItem((*pB).PrgId,(*pB).hFolders,Item,FOLDERNAME_SIZE + SUBFOLDERNAME_SIZE,(*pB).FullPath,pType);
4150 snprintf((
char*)pAnswer,Lng,
"%s/%s",(
char*)(*pB).FullPath,(
char*)(*pB).Filename);
4151 *pType = TYPE_BYTECODE;
4153 printf(
"Select folder %3d\r\n",Item);
4158 case BROWSE_FOLDS_FILES :
4161 (*pB).OpenFolder = (*pB).ItemPointer;
4162 cMemoryGetItem((*pB).PrgId,(*pB).hFolders,(*pB).OpenFolder,FOLDERNAME_SIZE + SUBFOLDERNAME_SIZE,(*pB).SubFolder,&TmpType);
4164 printf(
"Open folder %3d (%s)\r\n",(*pB).OpenFolder,(*pB).SubFolder);
4168 Item = (*pB).ItemPointer;
4169 cMemoryGetItemName((*pB).PrgId,(*pB).hFolders,Item,MAX_FILENAME_SIZE,(*pB).Filename,pType,&Priority);
4170 Result =
cMemoryGetItem((*pB).PrgId,(*pB).hFolders,Item,FOLDERNAME_SIZE + SUBFOLDERNAME_SIZE,(*pB).FullPath,pType);
4171 *pType = TYPE_SDCARD;
4173 snprintf((
char*)pAnswer,Lng,
"%s",(
char*)(*pB).FullPath);
4179 Item = (*pB).ItemPointer;
4180 cMemoryGetItemName((*pB).PrgId,(*pB).hFolders,Item,MAX_FILENAME_SIZE,(*pB).Filename,pType,&Priority);
4181 Result =
cMemoryGetItem((*pB).PrgId,(*pB).hFolders,Item,FOLDERNAME_SIZE + SUBFOLDERNAME_SIZE,(*pB).FullPath,pType);
4182 *pType = TYPE_USBSTICK;
4184 snprintf((
char*)pAnswer,Lng,
"%s",(
char*)(*pB).FullPath);
4188 (*pB).ItemStart = (*pB).ItemPointer;
4189 Result =
cMemoryOpenFolder(PrgId,FILETYPE_UNKNOWN,(*pB).SubFolder,&(*pB).hFiles);
4200 Item = (*pB).ItemPointer;
4202 *pType =
cMemoryGetCacheName(Item,FOLDERNAME_SIZE + SUBFOLDERNAME_SIZE,(
char*)(*pB).FullPath,(
char*)(*pB).Filename);
4203 snprintf((
char*)pAnswer,Lng,
"%s",(
char*)(*pB).FullPath);
4206 printf(
"Select folder %3d\r\n",Item);
4214 if (((*pB).ItemPointer > (*pB).OpenFolder) && ((*pB).ItemPointer <= ((*pB).OpenFolder + (*pB).Files)))
4217 Item = (*pB).ItemPointer - (*pB).OpenFolder;
4219 Result =
cMemoryGetItem((*pB).PrgId,(*pB).hFiles,Item,Lng,(*pB).FullPath,pType);
4221 snprintf((
char*)pAnswer,Lng,
"%s",(
char*)(*pB).FullPath);
4224 printf(
"Select file %3d\r\n",Item);
4232 (*pB).NeedUpdate = 1;
4235 TotalItems = (*pB).Folders + (*pB).Files;
4236 if (TmpResult == OK)
4240 if ((*pB).ItemPointer > TotalItems)
4243 (*pB).ItemPointer = TotalItems;
4244 (*pB).NeedUpdate = 1;
4246 if ((*pB).ItemStart > (*pB).ItemPointer)
4248 (*pB).ItemStart = (*pB).ItemPointer;
4249 (*pB).NeedUpdate = 1;
4254 (*pB).ItemStart = 1;
4255 (*pB).ItemPointer = 1;
4263 (*pB).NeedUpdate = 1;
4266 (*pB).ItemPointer += Tmp;
4267 if ((*pB).ItemPointer < 1)
4269 (*pB).ItemPointer = 1;
4270 (*pB).NeedUpdate = 0;
4272 if ((*pB).ItemPointer > TotalItems)
4274 (*pB).ItemPointer = TotalItems;
4275 (*pB).NeedUpdate = 0;
4280 if ((*pB).ItemPointer < (*pB).ItemStart)
4282 if ((*pB).ItemPointer > 0)
4284 (*pB).ItemStart = (*pB).ItemPointer;
4287 if ((*pB).ItemPointer >= ((*pB).ItemStart + (*pB).Lines))
4289 (*pB).ItemStart = (*pB).ItemPointer - (*pB).Lines;
4293 if ((*pB).NeedUpdate)
4296 (*pB).NeedUpdate = 0;
4299 #ifndef DISABLE_SDCARD_SUPPORT
4302 printf(
"SDCARD\r\n");
4305 #ifndef DISABLE_USBSTICK_SUPPORT
4308 printf(
"USBSTICK\r\n");
4311 printf(
"Folders = %3d, OpenFolder = %3d, Files = %3d, ItemStart = %3d, ItemPointer = %3d, TotalItems = %3d\r\n\n",(*pB).Folders,(*pB).OpenFolder,(*pB).Files,(*pB).ItemStart,(*pB).ItemPointer,TotalItems);
4315 dLcdFillRect((*UiInstance.
pLcd).Lcd,
BG_COLOR,(*pB).ScreenStartX,(*pB).ScreenStartY,(*pB).ScreenWidth,(*pB).ScreenHeight);
4318 for (Tmp = 0;Tmp < (*pB).Lines;Tmp++)
4320 Item = Tmp + (*pB).ItemStart;
4322 Priority = OldPriority;
4324 if (Item <= TotalItems)
4326 if ((*pB).OpenFolder)
4328 if ((Item > (*pB).OpenFolder) && (Item <= ((*pB).OpenFolder + (*pB).Files)))
4330 Item -= (*pB).OpenFolder;
4335 if (Item > (*pB).OpenFolder)
4337 Item -= (*pB).Files;
4342 if ((*pB).ItemPointer == (Tmp + (*pB).ItemStart))
4359 case BROWSE_FOLDERS :
4361 cMemoryGetItemName((*pB).PrgId,(*pB).hFolders,Item,(*pB).Chars,(*pB).Filename,&TmpType,&Priority);
4364 dLcdDrawBitmap((*UiInstance.
pLcd).Lcd,Color,(*pB).IconStartX,(*pB).IconStartY + (Tmp * (*pB).LineHeight),(
IP)Image);
4369 dLcdDrawPicture((*UiInstance.
pLcd).Lcd,Color,(*pB).IconStartX,(*pB).IconStartY + (Tmp * (*pB).LineHeight),PCApp_width,PCApp_height,(
UBYTE*)PCApp_bits);
4373 if (strcmp((
char*)(*pB).Filename,
"Bluetooth") == 0)
4375 if (UiInstance.
BtOn)
4377 (*pB).Text[0] =
'+';
4381 (*pB).Text[0] =
'-';
4386 if (strcmp((
char*)(*pB).Filename,
"WiFi") == 0)
4390 (*pB).Text[0] =
'+';
4394 (*pB).Text[0] =
'-';
4399 if (
cMemoryGetItemText((*pB).PrgId,(*pB).hFolders,Item,(*pB).Chars,(*pB).Text) != OK)
4405 switch ((*pB).Text[0])
4414 Indent = ((*pB).Chars - 1) * (*pB).CharWidth -
dLcdGetIconWidth(MENU_ICON);
4415 dLcdDrawIcon((*UiInstance.
pLcd).Lcd,Color,(*pB).TextStartX + Indent,((*pB).TextStartY - 2) + (Tmp * (*pB).LineHeight),MENU_ICON,ICON_CHECKED);
4421 Indent = ((*pB).Chars - 1) * (*pB).CharWidth -
dLcdGetIconWidth(MENU_ICON);
4422 dLcdDrawIcon((*UiInstance.
pLcd).Lcd,Color,(*pB).TextStartX + Indent,((*pB).TextStartY - 2) + (Tmp * (*pB).LineHeight),MENU_ICON,ICON_CHECKBOX);
4428 Indent = (((*pB).Chars - 1) - (
DATA16)strlen((
char*)(*pB).Text)) * (*pB).CharWidth;
4429 dLcdDrawText((*UiInstance.
pLcd).Lcd,Color,(*pB).TextStartX + Indent,(*pB).TextStartY + (Tmp * (*pB).LineHeight),NORMAL_FONT,(*pB).Text);
4438 case BROWSE_FOLDS_FILES :
4440 cMemoryGetItemName((*pB).PrgId,(*pB).hFolders,Item,(*pB).Chars,(*pB).Filename,&TmpType,&Priority);
4441 dLcdDrawIcon((*UiInstance.
pLcd).Lcd,Color,(*pB).IconStartX,(*pB).IconStartY + (Tmp * (*pB).LineHeight),NORMAL_ICON,FiletypeToNormalIcon[TmpType]);
4443 if ((Priority == 1) || (Priority == 2))
4445 dLcdDrawIcon((*UiInstance.
pLcd).Lcd,Color,(*pB).IconStartX,(*pB).IconStartY + (Tmp * (*pB).LineHeight),NORMAL_ICON,ICON_FOLDER2);
4451 dLcdDrawIcon((*UiInstance.
pLcd).Lcd,Color,(*pB).IconStartX,(*pB).IconStartY + (Tmp * (*pB).LineHeight),NORMAL_ICON,ICON_SD);
4457 dLcdDrawIcon((*UiInstance.
pLcd).Lcd,Color,(*pB).IconStartX,(*pB).IconStartY + (Tmp * (*pB).LineHeight),NORMAL_ICON,ICON_USB);
4461 dLcdDrawIcon((*UiInstance.
pLcd).Lcd,Color,(*pB).IconStartX,(*pB).IconStartY + (Tmp * (*pB).LineHeight),NORMAL_ICON,FiletypeToNormalIcon[TmpType]);
4465 if (Priority != OldPriority)
4467 if ((Priority == 1) || (Priority >= 3))
4471 dLcdDrawDotLine((*UiInstance.
pLcd).Lcd,Color,(*pB).SelectStartX,(*pB).SelectStartY + ((Tmp - 1) * (*pB).LineHeight) + (*pB).LineHeight - 2,(*pB).SelectStartX + (*pB).SelectWidth,(*pB).SelectStartY + ((Tmp - 1) * (*pB).LineHeight) + (*pB).LineHeight - 2,1,2);
4480 TmpType =
cMemoryGetCacheName(Item,(*pB).Chars,(
char*)(*pB).FullPath,(
char*)(*pB).Filename);
4481 dLcdDrawIcon((*UiInstance.
pLcd).Lcd,Color,(*pB).IconStartX,(*pB).IconStartY + (Tmp * (*pB).LineHeight),NORMAL_ICON,FiletypeToNormalIcon[TmpType]);
4487 cMemoryGetItemName((*pB).PrgId,(*pB).hFiles,Item,(*pB).Chars,(*pB).Filename,&TmpType,&Priority);
4488 dLcdDrawIcon((*UiInstance.
pLcd).Lcd,Color,(*pB).IconStartX,(*pB).IconStartY + (Tmp * (*pB).LineHeight),NORMAL_ICON,FiletypeToNormalIcon[TmpType]);
4494 dLcdDrawText((*UiInstance.
pLcd).Lcd,Color,(*pB).TextStartX,(*pB).TextStartY + (Tmp * (*pB).LineHeight),NORMAL_FONT,(*pB).Filename);
4497 if (Item == (*pB).OpenFolder)
4499 dLcdDrawIcon((*UiInstance.
pLcd).Lcd,Color,144,(*pB).IconStartY + (Tmp * (*pB).LineHeight),NORMAL_ICON,ICON_OPENFOLDER);
4503 if ((*pB).ItemPointer == (Tmp + (*pB).ItemStart))
4505 dLcdInverseRect((*UiInstance.
pLcd).Lcd,(*pB).SelectStartX,(*pB).SelectStartY + (Tmp * (*pB).LineHeight),(*pB).SelectWidth + 1,(*pB).SelectHeight);
4511 case BROWSE_FOLDERS :
4512 case BROWSE_FOLDS_FILES :
4515 if (((Tmp + (*pB).ItemStart) == TotalItems) && (Tmp < ((*pB).Lines - 1)))
4517 dLcdDrawDotLine((*UiInstance.
pLcd).Lcd,Color,(*pB).SelectStartX,(*pB).SelectStartY + (Tmp * (*pB).LineHeight) + (*pB).LineHeight - 2,(*pB).SelectStartX + (*pB).SelectWidth,(*pB).SelectStartY + (Tmp * (*pB).LineHeight) + (*pB).LineHeight - 2,1,2);
4524 if (((Tmp + (*pB).ItemStart) == 1) && (Tmp < ((*pB).Lines - 1)))
4526 dLcdDrawDotLine((*UiInstance.
pLcd).Lcd,Color,(*pB).SelectStartX,(*pB).SelectStartY + (Tmp * (*pB).LineHeight) + (*pB).LineHeight - 2,(*pB).SelectStartX + (*pB).SelectWidth,(*pB).SelectStartY + (Tmp * (*pB).LineHeight) + (*pB).LineHeight - 2,1,2);
4528 if (((Tmp + (*pB).ItemStart) == TotalItems) && (Tmp < ((*pB).Lines - 1)))
4530 dLcdDrawDotLine((*UiInstance.
pLcd).Lcd,Color,(*pB).SelectStartX,(*pB).SelectStartY + (Tmp * (*pB).LineHeight) + (*pB).LineHeight - 2,(*pB).SelectStartX + (*pB).SelectWidth,(*pB).SelectStartY + (Tmp * (*pB).LineHeight) + (*pB).LineHeight - 2,1,2);
4538 printf(
"%s %d %d %d\r\n",(
char*)(*pB).Filename,Item,(*pB).OpenFolder,Priority);
4545 cMemoryGetItemName((*pB).PrgId,(*pB).hFiles,Item,(*pB).Chars - 1,(*pB).Filename,&TmpType,&Priority);
4548 dLcdDrawIcon((*UiInstance.
pLcd).Lcd,Color,(*pB).IconStartX + (*pB).CharWidth,(*pB).IconStartY + (Tmp * (*pB).LineHeight),NORMAL_ICON,FiletypeToNormalIcon[TmpType]);
4551 dLcdDrawText((*UiInstance.
pLcd).Lcd,Color,(*pB).TextStartX + (*pB).CharWidth,(*pB).TextStartY + (Tmp * (*pB).LineHeight),NORMAL_FONT,(*pB).Filename);
4554 if ((Tmp == ((*pB).Lines - 1)) || (Item == (*pB).Files))
4556 dLcdDrawLine((*UiInstance.
pLcd).Lcd,Color,(*pB).IconStartX + (*pB).CharWidth - 3,(*pB).SelectStartY + (Tmp * (*pB).LineHeight),(*pB).IconStartX + (*pB).CharWidth - 3,(*pB).SelectStartY + (Tmp * (*pB).LineHeight) + (*pB).SelectHeight - 1);
4560 dLcdDrawLine((*UiInstance.
pLcd).Lcd,Color,(*pB).IconStartX + (*pB).CharWidth - 3,(*pB).SelectStartY + (Tmp * (*pB).LineHeight),(*pB).IconStartX + (*pB).CharWidth - 3,(*pB).SelectStartY + (Tmp * (*pB).LineHeight) + (*pB).LineHeight - 1);
4564 if ((*pB).ItemPointer == (Tmp + (*pB).ItemStart))
4566 dLcdInverseRect((*UiInstance.
pLcd).Lcd,(*pB).SelectStartX + (*pB).CharWidth,(*pB).SelectStartY + (Tmp * (*pB).LineHeight),(*pB).SelectWidth + 1 - (*pB).CharWidth,(*pB).SelectHeight);
4570 printf(
" | %s\r\n",(
char*)(*pB).Filename);
4583 OldPriority = Priority;
4589 cUiDrawBar(1,(*pB).ScrollStartX,(*pB).ScrollStartY,(*pB).ScrollWidth,(*pB).ScrollHeight,0,TotalItems,(*pB).ItemPointer);
4607 if (Type != BROWSE_CACHE)
4609 if ((*pB).OpenFolder)
4623 (*pB).SubFolder[0] = 0;
4628 printf(
"%d %d Closing browser with [%s] type [%d]\r\n",PrgId,ObjId,(
char*)pAnswer,*pType);
4635 (*pB).NeedUpdate = 1;
4641 *pType = TYPE_RESTART_BROWSER;
4647 #ifndef DISABLE_SDCARD_SUPPORT
4650 *pType |= TYPE_SDCARD;
4653 #ifndef DISABLE_USBSTICK_SUPPORT
4656 *pType |= TYPE_USBSTICK;
4666 printf(
"%d %d Return from browser with [%s] type [0x%02X]\r\n\n",PrgId,ObjId,(
char*)pAnswer,*pType);
4674 static char Delimiter[][3] =
4679 [DEL_RETURN] =
"\r",
4682 [DEL_LINEFEED] =
"\n",
4683 [DEL_CRLF] =
"\r\n",
4695 while (pText[Point] && (Point < Size))
4698 while ((pText[Point]) && (Point < Size) && (Delimiter[Del][DelPoi]) && (pText[Point] == Delimiter[Del][DelPoi]))
4703 if (Delimiter[Del][DelPoi] == 0)
4709 if ((pText[Point]) && (Point < Size))
4728 while ((pText[Point]) && (Point < Size))
4732 if ((Point < Size) && (Font))
4734 pText[Point] = Font;
4738 while ((Point < Size) && (*pLine))
4740 pText[Point] = *pLine;
4744 while ((Point < Size) && (Delimiter[Del][DelPoi]))
4746 pText[Point] = Delimiter[Del][DelPoi];
4764 while ((Line) && (pText[Point]) && (Point < Size))
4768 while ((pText[Point]) && (Point < Size) && (Delimiter[Del][DelPoi]) && (pText[Point] == Delimiter[Del][DelPoi]))
4773 if (Delimiter[Del][DelPoi] == 0)
4783 if ((pText[Point]) && (Point < Size))
4795 if ((pText[Result] > 0) && (pText[Result] < FONTTYPES))
4797 *pFont = pText[Result];
4820 while ((Run) && (pText[Point]) && (Point < Size))
4823 while ((pText[Point]) && (Point < Size) && (Delimiter[Del][DelPoi]) && (pText[Point] == Delimiter[Del][DelPoi]))
4828 if (Delimiter[Del][DelPoi] == 0)
4834 if ((pText[Point]) && (Point < Size))
4842 if (((Point - Start) + 1) < (
DATA32)Lng)
4844 Lng = (
DATA8)(Point - Start) + 1;
4846 snprintf((
char*)pLine,Lng,
"%s",(
char*)&pText[Start]);
4853 RESULT Result = BUSY;
4868 (*pB).ScreenStartX = X;
4869 (*pB).ScreenStartY = Y;
4870 (*pB).ScreenWidth = X1;
4871 (*pB).ScreenHeight = Y1;
4873 (*pB).Font = UiInstance.
Font;
4878 (*pB).Chars = ((*pB).ScreenWidth / (*pB).CharWidth);
4881 (*pB).LineSpace = 5;
4882 (*pB).LineHeight = (*pB).CharHeight + (*pB).LineSpace;
4883 (*pB).Lines = ((*pB).ScreenHeight / (*pB).LineHeight);
4886 (*pB).TextStartX =
cUiAlignX((*pB).ScreenStartX);
4887 (*pB).TextStartY = (*pB).ScreenStartY + ((*pB).LineHeight - (*pB).CharHeight) / 2;
4890 (*pB).SelectStartX = (*pB).ScreenStartX;
4891 (*pB).SelectWidth = (*pB).ScreenWidth - ((*pB).CharWidth + 5);
4892 (*pB).SelectStartY = (*pB).TextStartY - 1;
4893 (*pB).SelectHeight = (*pB).CharHeight + 1;
4896 (*pB).ScrollWidth = 5;
4897 (*pB).NobHeight = 7;
4898 (*pB).ScrollStartX = (*pB).ScreenStartX + (*pB).ScreenWidth - (*pB).ScrollWidth;
4899 (*pB).ScrollStartY = (*pB).ScreenStartY + 1;
4900 (*pB).ScrollHeight = (*pB).ScreenHeight - 2;
4901 (*pB).ScrollSpan = (*pB).ScrollHeight - (*pB).NobHeight;
4904 (*pB).ItemStart = 1;
4905 (*pB).ItemPointer = 1;
4907 (*pB).NeedUpdate = 1;
4912 TotalItems = (*pB).Items;
4918 (*pB).NeedUpdate = 1;
4921 (*pB).ItemPointer += Tmp;
4922 if ((*pB).ItemPointer < 1)
4924 (*pB).ItemPointer = 1;
4925 (*pB).NeedUpdate = 0;
4927 if ((*pB).ItemPointer > TotalItems)
4929 (*pB).ItemPointer = TotalItems;
4930 (*pB).NeedUpdate = 0;
4935 if ((*pB).ItemPointer < (*pB).ItemStart)
4937 if ((*pB).ItemPointer > 0)
4939 (*pB).ItemStart = (*pB).ItemPointer;
4942 if ((*pB).ItemPointer >= ((*pB).ItemStart + (*pB).Lines))
4944 (*pB).ItemStart = (*pB).ItemPointer - (*pB).Lines;
4950 *pLine = (*pB).ItemPointer;
4962 if ((*pB).NeedUpdate)
4965 (*pB).NeedUpdate = 0;
4968 dLcdFillRect((*UiInstance.
pLcd).Lcd,
BG_COLOR,(*pB).ScreenStartX,(*pB).ScreenStartY,(*pB).ScreenWidth,(*pB).ScreenHeight);
4970 Ypos = (*pB).TextStartY + 2;
4972 for (Tmp = 0;Tmp < (*pB).Lines;Tmp++)
4974 Item = Tmp + (*pB).ItemStart;
4976 if (Item <= TotalItems)
4985 (*pB).LineSpace = 2;
4986 (*pB).LineHeight = (*pB).CharHeight + (*pB).LineSpace;
4987 (*pB).Lines = ((*pB).ScreenHeight / (*pB).LineHeight);
4990 (*pB).SelectStartX = (*pB).ScreenStartX;
4991 (*pB).SelectWidth = (*pB).ScreenWidth - ((*pB).ScrollWidth + 2);
4992 (*pB).SelectStartY = (*pB).TextStartY - 1;
4993 (*pB).SelectHeight = (*pB).CharHeight + 1;
4995 (*pB).Chars = ((*pB).SelectWidth / (*pB).CharWidth);
4997 (*pB).Text[(*pB).Chars] = 0;
4999 if ((Ypos + (*pB).LineHeight) <= ((*pB).ScreenStartY + (*pB).ScreenHeight))
5001 dLcdDrawText((*UiInstance.
pLcd).Lcd,Color,(*pB).TextStartX,Ypos,(*pB).Font,(*pB).Text);
5009 cUiDrawBar(1,(*pB).ScrollStartX,(*pB).ScrollStartY,(*pB).ScrollWidth,(*pB).ScrollHeight,0,TotalItems,(*pB).ItemPointer);
5011 if ((Ypos + (*pB).LineHeight) <= ((*pB).ScreenStartY + (*pB).ScreenHeight))
5014 if ((*pB).ItemPointer == (Tmp + (*pB).ItemStart))
5016 dLcdInverseRect((*UiInstance.
pLcd).Lcd,(*pB).SelectStartX,Ypos - 1,(*pB).SelectWidth,(*pB).LineHeight);
5019 Ypos += (*pB).LineHeight;
5059 for (Item = 0;Item < UiInstance.
Graph.
Items;Item++)
5087 for (Item = 0;Item < (UiInstance.
Graph.
Items);Item++)
5092 if (!(isnan(Sample)))
5106 for (Item = 0;Item < (UiInstance.
Graph.
Items);Item++)
5108 for (Pointer = 0;Pointer < (UiInstance.
Graph.
GraphSizeX - 1);Pointer++)
5116 if (!(isnan(Sample)))
5155 if ((View >= 0) && (View < UiInstance.
Graph.
Items))
5163 for (Pointer = 0;Pointer < UiInstance.
Graph.
Pointer;Pointer++)
5166 if (!(isnan(Sample)))
5169 if (isnan(*pAverage))
5171 *pAverage = (
DATAF)0;
5172 *pLowest = *pActual;
5173 *pHighest = *pActual;
5177 if (*pActual < *pLowest)
5179 *pLowest = *pActual;
5181 if (*pActual > *pHighest)
5183 *pHighest = *pActual;
5186 *pAverage += *pActual;
5238 *pAverage = *pAverage / (
DATAF)Samples;
5245 for (Item = 0;Item < UiInstance.
Graph.
Items;Item++)
5250 for (Pointer = 0;Pointer < UiInstance.
Graph.
Pointer;Pointer++)
5609 if ((TmpPrgId != GUI_SLOT) && (TmpPrgId != DEBUG_SLOT))
5650 UiInstance.
Font = NORMAL_FONT;
5677 if (
cUiTextbox(X,Y,X1,Y1,pText,Size,Del,pLine) == BUSY)
5889 for (Lng = 0;Lng < Figures;Lng++)
5898 Figures = 0 - Figures;
5899 snprintf((
char*)GBuffer,24,
"%.*f",Decimals,DataF);
5903 snprintf((
char*)GBuffer,24,
"%*.*f",Figures,Decimals,DataF);
5905 if (GBuffer[0] ==
'-')
5911 GBuffer[Figures] = 0;
5935 X1 = ((CharWidth + 2) / 3) - 1;
5936 Y1 = (CharHeight / 2);
5942 if (GBuffer[0] ==
'-')
5947 pText = &GBuffer[1];
5952 TmpColor = 1 - Color;
5957 dLcdDrawLine((*UiInstance.
pLcd).Lcd,1 - Color,X - X1,Y + Y1,X + (Figures * CharWidth),Y + Y1);
5958 if (CharHeight > 12)
5960 dLcdDrawLine((*UiInstance.
pLcd).Lcd,1 - Color,X - X1,Y + Y1 - 1,X + (Figures * CharWidth),Y + Y1 - 1);
5965 while((pText[Tmp] != 0) && (pText[Tmp] !=
'n'))
5969 if (pText[Tmp] ==
'n')
5972 for (Tmp = 0;Tmp < (
DATA16)Figures;Tmp++)
5988 for (Tmp = 0;Tmp < (
DATA16)Figures;Tmp++)
5995 TmpColor = 1 - Color;
5998 Tmp = ((
DATA16)Figures - Lng) * CharWidth;
6004 Tmp = ((((
DATA16)Figures - Lng) + 1) / 2) * CharWidth;
6011 dLcdDrawLine((*UiInstance.
pLcd).Lcd,TmpColor,X - X1 + Tmp,Y + Y1,X + Tmp,Y + Y1);
6012 if (CharHeight > 12)
6014 dLcdDrawLine((*UiInstance.
pLcd).Lcd,TmpColor,X - X1 + Tmp,Y + Y1 - 1,X + Tmp,Y + Y1 - 1);
6039 X1 = ((CharWidth + 2) / 3) - 1;
6040 Y1 = (CharHeight / 2);
6046 if (GBuffer[0] ==
'-')
6051 pText = &GBuffer[1];
6056 TmpColor = 1 - Color;
6061 dLcdDrawLine((*UiInstance.
pLcd).Lcd,1 - Color,X - X1,Y + Y1,X + (Figures * CharWidth),Y + Y1);
6062 if (CharHeight > 12)
6064 dLcdDrawLine((*UiInstance.
pLcd).Lcd,1 - Color,X - X1,Y + Y1 - 1,X + (Figures * CharWidth),Y + Y1 - 1);
6069 while((pText[Tmp] != 0) && (pText[Tmp] !=
'n'))
6073 if (pText[Tmp] ==
'n')
6076 for (Tmp = 0;Tmp < (
DATA16)Figures;Tmp++)
6092 for (Tmp = 0;Tmp < (
DATA16)Figures;Tmp++)
6099 TmpColor = 1 - Color;
6102 Tmp = ((
DATA16)Figures - Lng) * CharWidth;
6108 Tmp = ((((
DATA16)Figures - Lng) + 1) / 2) * CharWidth;
6116 dLcdDrawLine((*UiInstance.
pLcd).Lcd,TmpColor,X - X1 + Tmp,Y + Y1,X + Tmp,Y + Y1);
6117 if (CharHeight > 12)
6119 dLcdDrawLine((*UiInstance.
pLcd).Lcd,TmpColor,X - X1 + Tmp,Y + Y1 - 1,X + Tmp,Y + Y1 - 1);
6122 Tmp = ((((
DATA16)Lng))) * CharWidth;
6123 snprintf((
char*)GBuffer,Length,
"%s",pUnit);
6146 if (
cUiNotification(Color,X,Y,Icon1,Icon2,Icon3,pText,pState) == BUSY)
6173 if (
cUiQuestion(Color,X,Y,Icon1,Icon2,pText,pState,pAnswer) == BUSY)
6188 case ICON_QUESTION :
6231 SelectedChar =
cUiKeyboard(Color,X,Y,No,Lng,pText,pCharSet,pAnswer);
6234 if (SelectedChar != 0x0D)
6266 if (
cUiBrowser(Type,X,Y,X1,Y1,Lng,pType,pAnswer) == BUSY)
6303 if (UiInstance.
Font >= FONTTYPES)
6305 UiInstance.
Font = (FONTTYPES - 1);
6307 if (UiInstance.
Font < 0)
6309 UiInstance.
Font = 0;
6328 UiInstance.
Font = NORMAL_FONT;
6332 if ((Color == 0) || (Color == 1))
6349 memset(&((*UiInstance.
pLcd).Lcd[Y]),Color,Y1);
6358 for (Tmp = Y;Tmp < Y1;Tmp++)
6361 memset(&((*UiInstance.
pLcd).Lcd[Y3]),Color,Y2);
6621 DATA8 *pDestination;
6640 if (UiInstance.
Keys)
6646 while ((UiInstance.
Keys) && (Lng))
6648 *pDestination = *pSource;
6672 for (Lng = 0;Lng < UiInstance.
KeyBufIn;Lng++)
6676 #ifdef DEBUG_TRACE_KEY
6677 printf(
"%s",(
char*)UiInstance.
KeyBuffer);
6719 if (UiInstance.
Keys)
6722 UiInstance.
Keys = 0;
6734 if (UiInstance.
Keys)
6746 (*pImgHead).Sign[0] =
'l';
6747 (*pImgHead).Sign[1] =
'e';
6748 (*pImgHead).Sign[2] =
'g';
6749 (*pImgHead).Sign[3] =
'o';
6750 (*pImgHead).ImageSize = 0;
6751 (*pImgHead).VersionInfo = (
UWORD)(VERS * 100.0);
6752 (*pImgHead).NumberOfObjects = 1;
6753 (*pImgHead).GlobalBytes = 0;
6756 (*pObjHead).OwnerObjectId = 0;
6757 (*pObjHead).TriggerCount = 0;
6758 (*pObjHead).LocalBytes = MAX_COMMAND_LOCALS;
6765 while ((UiInstance.
Keys) && (Length))
6770 if (UiInstance.
Keys)
6780 *pDestination = Tmp;
6785 *pDestination = opOBJECT_END;
6787 (*pImgHead).ImageSize = Size;
6809 Data8 = (
DATA8)strlen((
char*)UiInstance.
HwVers) + 1;
6810 if ((Lng > Data8) || (Lng == -1))
6816 if (pDestination !=
NULL)
6830 Data8 = (
DATA8)strlen((
char*)UiInstance.
FwVers) + 1;
6831 if ((Lng > Data8) || (Lng == -1))
6837 if (pDestination !=
NULL)
6852 if ((Lng > Data8) || (Lng == -1))
6858 if (pDestination !=
NULL)
6872 Data8 = (
DATA8)strlen((
char*)UiInstance.
OsVers) + 1;
6873 if ((Lng > Data8) || (Lng == -1))
6879 if (pDestination !=
NULL)
6894 if ((Lng > Data8) || (Lng == -1))
6900 if (pDestination !=
NULL)
6917 if ((Lng > Data8) || (Lng == -1))
6923 if (pDestination !=
NULL)
6938 if ((Lng > Data8) || (Lng == -1))
6944 if (pDestination !=
NULL)
6988 UiInstance.
Event = 0;
7153 snprintf((
char*)Buffer,32,
"%*.*f",Figures,Decimals,DataF);
7184 pSource = (
DATA8*)pGlobal;
7187 for (Tmp = 0;Tmp < Data32;Tmp++)
7189 snprintf((
char*)Buffer,7,
"%02X ",pSource[Tmp] & 0xFF);
7191 if (((Tmp & 0x3) == 0x3) && ((Tmp & 0xF) != 0xF))
7195 if (((Tmp & 0xF) == 0xF) && (Tmp < (Data32 - 1)))
7205 case TEXTBOX_APPEND :
7240 snprintf((
char*)Buffer,7,
"%d",(
int)Data8);
7257 snprintf((
char*)Buffer,9,
"%d",Data16 & 0xFFFF);
7274 snprintf((
char*)Buffer,14,
"%ld",(
long unsigned int)(Data32 & 0xFFFFFFFF));
7290 snprintf((
char*)Buffer,24,
"%f",DataF);
7304 if (Data8 >= LEDPATTERNS)
7306 Data8 = LEDPATTERNS - 1;
7321 ioctl(UiInstance.
PowerFile,0,(
size_t)&Data8);
7597 case WAIT_FOR_PRESS :
7635 case SET_BACK_BLOCK :
7641 case GET_BACK_BLOCK :
7647 case TESTSHORTPRESS :
7659 case TESTLONGPRESS :
7674 UiInstance.
Click = 0;
#define BUTTON_BUMBED
button has been pressed and released
DATA8 cUiWaitForPress(void)
DSPSTAT ExecuteByteCode(IP pByteCode, GP pGlobals, LP pLocals)
Execute byte code stream (C-call)
void SetDispatchStatus(DSPSTAT DspStat)
Set object (dispatch) status.
DATA8 cUiKeyboard(DATA8 Color, DATA16 X, DATA16 Y, DATA8 Icon, DATA8 Lng, DATA8 *pText, DATA8 *pCharSet, DATA8 *pAnswer)
RESULT cUiUpdateInput(void)
#define vmPOP3_ABS_WARN_YES_X
void cUiTextboxReadLine(DATA8 *pText, DATA32 Size, DATA8 Del, DATA8 Lng, DATA16 Line, DATA8 *pLine, DATA8 *pFont)
#define BUTTON_PRESSED
button is pressed at the moment
#define LCD_STORE_LEVELS
Store levels.
const DATA8 FiletypeToNormalIcon[FILETYPES]
#define vmPOP3_ABS_WARN_ICON_X2
IMGDATA DownloadSuccesSound[]
void cUiButtonFlush(void)
RESULT cMemoryGetImage(DATA8 *pFileName, DATA16 Size, UBYTE *pBmp)
IMGDATA Globals[MAX_COMMAND_GLOBALS]
void cUiUpdatePower(void)
void dLcdScroll(UBYTE *pImage, DATA16 Y0)
UBYTE VARDATA
Variable base type.
#define BG_COLOR
Background color.
void cUiWriteString(DATA8 *pString)
DATA8 GetTerminalEnable(void)
void cUiButton(void)
opUI_BUTTON byte code
DATA8 CheckUsbstick(DATA8 *pChanged, DATA32 *pTotal, DATA32 *pFree, DATA8 Force)
SWORD DATA16
VM Type for 2 byte signed value.
#define vmPOP3_ABS_WARN_YES_Y
DATA16 dLcdGetFontWidth(DATA8 Font)
void LogErrorNumber(ERR Err)
SLONG DATA32
VM Type for 4 byte signed value.
DATA8 Name[FILENAME_SIZE]
#define MAX_NOTIFY_LINE_CHARS
void cMemoryCloseFolder(PRGID PrgId, HANDLER *pHandle)
UBYTE TopLineBattIconMap[TOP_BATT_ICONS]
UWORD OBJID
Object id type.
void cUiSetPress(DATA8 Button, DATA8 Press)
#define vmPOP3_ABS_WARN_SPEC_ICON_Y
void SetObjectIp(IP Ip)
Set current instruction pointer.
RESULT ValidateChar(DATA8 *pChar, DATA8 Set)
UBYTE cComGetBtStatus(void)
void cUiDownloadSuccesSound(void)
char * strptime(const char *s, const char *format, struct tm *tm)
void dLcdInit(UBYTE *pImage)
char FwBuild[FWBUILD_SIZE]
#define FINAL
Final prototype.
DATA8 cUiGetBumbed(DATA8 Button)
DATA8 cUiTestShortPress(DATA8 Button)
void cUiRead(void)
opUI_READ byte code
DATA16 HANDLER
Memory list index.
void cUiFlush(void)
opUI_FLUSH byte code
RESULT cUiTextbox(DATA16 X, DATA16 Y, DATA16 X1, DATA16 Y1, DATA8 *pText, DATA32 Size, DATA8 Del, DATA16 *pLine)
void dLcdDrawText(UBYTE *pImage, DATA8 Color, DATA16 X0, DATA16 Y0, DATA8 Font, DATA8 *pText)
void * PrimParPointer(void)
Get next encoded parameter from byte code stream.
void cUiGraphSetup(DATA16 StartX, DATA16 SizeX, DATA8 Items, DATA16 *pOffset, DATA16 *pSpan, DATAF *pMin, DATAF *pMax, DATAF *pVal)
DATA8 KeyBuffer[KEYBUF_SIZE+1]
float battery_power_boost
void dLcdDrawIcon(UBYTE *pImage, DATA8 Color, DATA16 X0, DATA16 Y0, DATA8 Type, DATA8 No)
IP GetObjectIp(void)
Get current instruction pointer.
DATA8 cMemoryGetCacheName(DATA8 Item, DATA8 MaxLength, char *pFileName, char *pName)
DATA8 cUiNotification(DATA8 Color, DATA16 X, DATA16 Y, DATA8 Icon1, DATA8 Icon2, DATA8 Icon3, DATA8 *pText, DATA8 *pState)
DATA8 cUiQuestion(DATA8 Color, DATA16 X, DATA16 Y, DATA8 Icon1, DATA8 Icon2, DATA8 *pText, DATA8 *pState, DATA8 *pAnswer)
UI_GLOBALS * getUiInstance()
RESULT dTerminalExit(void)
OBJID CallingObjectId(void)
Get calling object id.
#define LCD_WIDTH
LCD horizontal pixels.
void dLcdDrawLine(UBYTE *pImage, DATA8 Color, DATA16 X0, DATA16 Y0, DATA16 X1, DATA16 Y1)
OBJSTAT ProgramStatus(PRGID PrgId)
Get program status.
void cUiWrite(void)
opUI_WRITE byte code
IMGDATA ImageBuffer[IMAGEBUFFER_SIZE]
#define vmPOP3_ABS_WARN_ICON_X1
IMGDATA * IP
Instruction pointer type.
RESULT dTerminalWrite(UBYTE *pData, UWORD Cnt)
DATAF Buffer[GRAPH_BUFFERS][GRAPH_BUFFER_SIZE]
ULONG CurrentObjectIp(void)
void dLcdDrawChar(UBYTE *pImage, DATA8 Color, DATA16 X0, DATA16 Y0, DATA8 Font, DATA8 Char)
DATA8 GetSleepMinutes(void)
void cUiTextboxAppendLine(DATA8 *pText, DATA32 Size, DATA8 Del, DATA8 *pLine, DATA8 Font)
void cUiGraphSample(void)
unsigned int ULONG
Basic Type used to symbolise 32 bit unsigned values.
UBYTE TopLineWifiIconMap[TOP_WIFI_ICONS]
DATA8 cUiButtonRemap(DATA8 Mapped)
void cUiKeepAlive(void)
opKEEP_ALIVE byte code
DATA16 dLcdGetFontHeight(DATA8 Font)
void cUiTestpin(DATA8 State)
#define UI_WR_BUFFER_SIZE
DATA16 cUiAlignX(DATA16 X)
#define vmPOP3_ABS_WARN_LINE_ENDX
DATA8 cComGetUsbStatus(void)
DATA32 cUiTextboxFindLine(DATA8 *pText, DATA32 Size, DATA8 Del, DATA16 Line, DATA8 *pFont)
DATA16 ButtonDebounceTimer[BUTTONS]
void dLcdUpdate(LCD *pDisp)
DATA16 ButtonTimer[BUTTONS]
#define vmPOP3_ABS_WARN_ICON_X
DSPSTAT cMemoryCloseFile(PRGID PrgId, HANDLER Handle)
void cUiUpdateButtons(DATA16 Time)
#define BUTTON_LONG_LATCH
#define BUTTON_LONGPRESS
button long press detected
#define FINALB
Schematics revision B and C.
LCD LcdPool[LCD_STORE_LEVELS]
void cUiUpdateTopline(void)
#define vmPOP3_ABS_WARN_ICON_Y
DATA8 cUiTestLongPress(DATA8 Button)
RESULT cMemoryGetItemName(PRGID PrgId, HANDLER Handle, DATA16 Item, DATA8 Length, DATA8 *pName, DATA8 *pType, DATA8 *pPriority)
void cMemoryGetUsage(DATA32 *pTotal, DATA32 *pFree, DATA8 Force)
RESULT dTerminalRead(UBYTE *pData)
DATA16 dLcdGetIconHeight(DATA8 Type)
DATA16 dLcdGetIconWidth(DATA8 Type)
RESULT cMemoryGetItemText(PRGID PrgId, HANDLER Handle, DATA16 Item, DATA8 Length, DATA8 *pText)
#define vmPOP3_ABS_WARN_SPEC_ICON_X
void cUiSetLed(DATA8 State)
RESULT cUiBrowser(DATA8 Type, DATA16 X, DATA16 Y, DATA16 X1, DATA16 Y1, DATA8 Lng, DATA8 *pType, DATA8 *pAnswer)
void dLcdInverseRect(UBYTE *pImage, DATA16 X0, DATA16 Y0, DATA16 X1, DATA16 Y1)
DATA8 cUiGetPress(DATA8 Button)
DATA8 MappedToReal[BUTTONTYPES]
void cUiCheckAlive(UWORD Time)
DATA16 ButtonRepeatTimer[BUTTONS]
#define LCDClearTopline(I)
void ProgramEnd(PRGID PrgId)
Exit program nicely (freeing up memory)
unsigned char UBYTE
Basic Type used to symbolise 8 bit unsigned values.
void SetTerminalEnable(DATA8 Value)
PRG Program[MAX_PROGRAMS]
Program[0] is the UI byte codes running.
DATA8 cMemoryGetCacheFiles(void)
#define BUTTONS
Number of buttons in the system.
void dLcdRect(UBYTE *pImage, DATA8 Color, DATA16 X0, DATA16 Y0, DATA16 X1, DATA16 Y1)
void setUiInstance(UI_GLOBALS *_Instance)
RESULT cMemoryGetItemIcon(PRGID PrgId, HANDLER Handle, DATA16 Item, HANDLER *pHandle, DATA32 *pImagePointer)
FLOAT DATAF
VM Type for 4 byte floating point value.
UBYTE cComGetWifiStatus(void)
UBYTE TopLineBtIconMap[TOP_BT_ICONS]
unsigned short UWORD
Basic Type used to symbolise 16 bit unsigned values.
UBYTE IMGDATA
Image base type.
void dLcdDrawDotLine(UBYTE *pImage, DATA8 Color, DATA16 X0, DATA16 Y0, DATA16 X1, DATA16 Y1, DATA16 On, DATA16 Off)
void dLcdAutoUpdate(void)
void cComGetBrickName(DATA8 Length, DATA8 *pBrickName)
void cUiGraphDraw(DATA8 View, DATAF *pActual, DATAF *pLowest, DATAF *pHighest, DATAF *pAverage)
float new_bat_temp(float V_bat, float I_bat)
#define vmPOP3_ABS_WARN_LINE_X
DATA8 ButtonState[BUTTONS]
#define vmPOP3_ABS_WARN_ICON_X3
DATA8 CheckSdcard(DATA8 *pChanged, DATA32 *pTotal, DATA32 *pFree, DATA8 Force)
PRGID CurrentProgramId(void)
Get current program id.
RESULT cMemoryGetItem(PRGID PrgId, HANDLER Handle, DATA16 Item, DATA8 Length, DATA8 *pName, DATA8 *pType)
void * VmMemoryResize(HANDLER Handle, DATA32 Elements)
void dLcdDrawCircle(UBYTE *pImage, DATA8 Color, DATA16 X0, DATA16 Y0, DATA16 R)
UWORD PRGID
Program id type.
#define FG_COLOR
Foreground color.
DATA8 cUiGetLongPress(DATA8 Button)
RESULT cMemoryOpenFolder(PRGID PrgId, DATA8 Type, DATA8 *pFolderName, HANDLER *pHandle)
SBYTE DATA8
VM Type for 1 byte signed value.
void dLcdDrawBitmap(UBYTE *pImage, DATA8 Color, DATA16 X0, DATA16 Y0, IP pBitmap)
#define TOPLINE_HEIGHT
Top line vertical pixels.
DATA8 cUiGetShortPress(DATA8 Button)
void cUiCheckMemory(void)
RESULT cMemoryGetFolderItems(PRGID PrgId, HANDLER Handle, DATA16 *pItems)
void cUiDrawBar(DATA8 Color, DATA16 X, DATA16 Y, DATA16 X1, DATA16 Y1, DATA16 Min, DATA16 Max, DATA16 Act)
#define BUTTON_ACTIVATED
button has been activated since last read
void dLcdFillRect(UBYTE *pImage, DATA8 Color, DATA16 X0, DATA16 Y0, DATA16 X1, DATA16 Y1)
void dLcdDrawFilledCircle(UBYTE *pImage, DATA8 Color, DATA16 X0, DATA16 Y0, DATA16 R)
void dLcdDrawPicture(UBYTE *pImage, DATA8 Color, DATA16 X0, DATA16 Y0, DATA16 IconWidth, DATA16 IconHeight, UBYTE *pIconBits)
void cUiCheckVoltage(void)
RESULT cUiIconQuestion(DATA8 Color, DATA16 X, DATA16 Y, DATA8 *pState, DATA32 *pIcons)
Object is stopped or not triggered yet.
RESULT dTerminalInit(void)
Break because of waiting for completion.
void dLcdDrawPixel(UBYTE *pImage, DATA8 Color, DATA16 X0, DATA16 Y0)
OBJSTAT ProgramStatusChange(PRGID PrgId)
Get program status change.
#define LCD_HEIGHT
LCD vertical pixels.
Dispatcher running (looping)
void cUiDraw(void)
opUI_DRAW byte code
float K_bat_gain_from_elec
#define vmPOP3_ABS_WARN_LINE_Y
char OsBuild[OSBUILD_SIZE]
DATA16 cUiTextboxGetLines(DATA8 *pText, DATA32 Size, DATA8 Del)
void cUiUpdate(UWORD Time)
DATA8 UiWrBuffer[UI_WR_BUFFER_SIZE]
float K_elec_gain_from_bat
IP OffsetToInstructions
Offset to instructions from image start.
void cUiFlushBuffer(void)