[CLI] reboot command added

This commit is contained in:
Bertrand Songis
2016-02-20 16:55:05 +01:00
parent 0f4f49b64e
commit 67a599e0b9
45 changed files with 920 additions and 605 deletions
+3 -3
View File
@@ -63,9 +63,9 @@ void GaugeWidget::refresh()
// Gauge
lcdSetColor(color);
lcdDrawSolidFilledRect(zone.x, zone.y + 15, zone.w, 16, TEXT_INVERTED_COLOR);
lcdDrawNumber((percent >= 100 ? 20 : (percent >= 10 ? 10 : 0)) + zone.x+zone.w/2, zone.y + 16, percent, SMLSIZE | CUSTOM_COLOR, 0, NULL, "%");
lcdInvertRect(zone.x + w, zone.y + 15, zone.w - w, 16, CUSTOM_COLOR);
lcdDrawSolidFilledRect(zone.x, zone.y + 16, zone.w, 16, TEXT_INVERTED_COLOR);
lcdDrawNumber((percent >= 100 ? 20 : (percent >= 10 ? 10 : 0)) + zone.x+zone.w/2, zone.y + 17, percent, SMLSIZE | CUSTOM_COLOR, 0, NULL, "%");
lcdInvertRect(zone.x + w, zone.y + 16, zone.w - w, 16, CUSTOM_COLOR);
}
BaseWidgetFactory<GaugeWidget> gaugeWidget("Gauge", GaugeWidget::options);
@@ -20,10 +20,10 @@
#include "opentx.h"
class ModelPanelWidget: public Widget
class ModelBitmapWidget: public Widget
{
public:
ModelPanelWidget(const WidgetFactory * factory, const Zone & zone, Widget::PersistentData * persistentData):
ModelBitmapWidget(const WidgetFactory * factory, const Zone & zone, Widget::PersistentData * persistentData):
Widget(factory, zone, persistentData)
{
}
@@ -31,26 +31,24 @@ class ModelPanelWidget: public Widget
virtual void refresh();
};
void ModelPanelWidget::refresh()
void ModelBitmapWidget::refresh()
{
if (zone.h >= MODEL_BITMAP_HEIGHT) {
lcdDrawFilledRect(zone.x, zone.y, zone.w, zone.h, SOLID, MAINVIEW_PANES_COLOR | OPACITY(5));
lcdDrawBitmapPattern(zone.x + 6, zone.y + 4, LBM_MODEL_ICON, MAINVIEW_GRAPHICS_COLOR);
lcdDrawSizedText(zone.x + 45, zone.y + 10, g_model.header.name, LEN_MODEL_NAME, ZCHAR | SMLSIZE);
lcdDrawSolidFilledRect(zone.x + 39, zone.y + 27, zone.w - 48, 2, MAINVIEW_GRAPHICS_COLOR);
int scale = getBitmapScale(modelBitmap, zone.w, zone.h - 25);
float scale = getBitmapScale(modelBitmap, zone.w, zone.h - 25);
int width = getBitmapScaledSize(getBitmapWidth(modelBitmap), scale);
int height = getBitmapScaledSize(getBitmapHeight(modelBitmap), scale);
lcdDrawBitmap(zone.x + (zone.w - width) / 2, zone.y + zone.h - height / 2 - height / 2, modelBitmap, 0, 0, scale);
}
else {
int scale = getBitmapScale(modelBitmap, zone.w, zone.h);
float scale = getBitmapScale(modelBitmap, 1000, zone.h);
int width = getBitmapScaledSize(getBitmapWidth(modelBitmap), scale);
int height = getBitmapScaledSize(getBitmapHeight(modelBitmap), scale);
lcdDrawFilledRect(zone.x, zone.y, zone.w, height, SOLID, MAINVIEW_PANES_COLOR | OPACITY(5));
lcdDrawSizedText(zone.x + 5, zone.y + 10, g_model.header.name, LEN_MODEL_NAME, ZCHAR | SMLSIZE);
lcdDrawBitmap(zone.x + zone.w - width, zone.y, modelBitmap, 0, 0, scale);
lcdDrawBitmap(zone.x + (zone.w - width) / 2, zone.y + (zone.h - height) / 2, modelBitmap, 0, 0, scale);
}
}
BaseWidgetFactory<ModelPanelWidget> modelPanelWidget("ModelPanel", NULL);
BaseWidgetFactory<ModelBitmapWidget> modelBitmapWidget("ModelBmp", NULL);
+24 -10
View File
@@ -41,21 +41,35 @@ const ZoneOption TimerWidget::options[] = {
void TimerWidget::refresh()
{
uint32_t index = persistentData->options[0].unsignedValue;
TimerData & timerData = g_model.timers[index];
TimerState & timerState = timersStates[index];
lcdDrawBitmapPattern(zone.x, zone.y, LBM_TIMER_BACKGROUND, MAINVIEW_PANES_COLOR);
if (timerData.start) {
lcdDrawBitmapPatternPie(zone.x+2, zone.y+3, LBM_RSCALE, MAINVIEW_GRAPHICS_COLOR, 0, timerState.val <= 0 ? 360 : 360*(timerData.start-timerState.val)/timerData.start);
if (zone.w >= 180 && zone.h >= 70) {
lcdDrawBitmapPattern(zone.x, zone.y, LBM_TIMER_BACKGROUND, MAINVIEW_PANES_COLOR);
if (timerData.start) {
lcdDrawBitmapPatternPie(
zone.x + 2,
zone.y + 3, LBM_RSCALE, MAINVIEW_GRAPHICS_COLOR, 0,
timerState.val <= 0 ? 360 : 360 * (timerData.start - timerState.val) / timerData.start);
}
else {
lcdDrawBitmapPattern(zone.x + 3, zone.y + 4, LBM_TIMER, MAINVIEW_GRAPHICS_COLOR);
}
putsTimer(zone.x + 76, zone.y + 31, abs(timerState.val), TEXT_COLOR | DBLSIZE | LEFT);
if (ZLEN(timerData.name) > 0) {
lcdDrawSizedText(zone.x + 78, zone.y + 20, timerData.name, LEN_TIMER_NAME, ZCHAR | SMLSIZE | TEXT_COLOR);
}
drawStringWithIndex(zone.x + 137, zone.y + 17, "TMR", index + 1, SMLSIZE | TEXT_COLOR);
}
else {
lcdDrawBitmapPattern(zone.x+3, zone.y+4, LBM_TIMER, MAINVIEW_GRAPHICS_COLOR);
drawStringWithIndex(zone.x, zone.y, "TMR", index + 1, SMLSIZE | TEXT_INVERTED_COLOR);
if (zone.w > 100) {
putsTimer(zone.x, zone.y + 16, abs(timerState.val), TEXT_INVERTED_COLOR | LEFT | MIDSIZE);
}
else {
putsTimer(zone.x, zone.y + 14, abs(timerState.val), TEXT_INVERTED_COLOR | LEFT);
}
}
putsTimer(zone.x+76, zone.y+31, abs(timerState.val), TEXT_COLOR|DBLSIZE|LEFT);
if (ZLEN(timerData.name) > 0) {
lcdDrawSizedText(zone.x+78, zone.y+20, timerData.name, LEN_TIMER_NAME, ZCHAR|SMLSIZE|TEXT_COLOR);
}
drawStringWithIndex(zone.x+137, zone.y+17, "TMR", index+1, SMLSIZE|TEXT_COLOR);
}
BaseWidgetFactory<TimerWidget> timerWidget("Timer", TimerWidget::options);
+22 -10
View File
@@ -44,23 +44,35 @@ void ValueWidget::refresh()
mixsrc_t field = persistentData->options[0].unsignedValue;
LcdFlags color = TEXT_COLOR;
LcdFlags color = TEXT_INVERTED_COLOR;
int x = zone.x;
int y = zone.y;
lcdDrawFilledRect(zone.x, zone.y, zone.w, zone.h, SOLID, MAINVIEW_PANES_COLOR | OPACITY(5));
// lcdDrawFilledRect(zone.x, zone.y, zone.w, zone.h, SOLID, MAINVIEW_PANES_COLOR | OPACITY(5));
int xValue, yValue;
LcdFlags attr;
if (zone.h < 50) {
int xValue, yValue, xLabel, yLabel;
LcdFlags attrValue, attrLabel=0;
if (zone.w < 120 && zone.h < 50) {
xValue = x;
yValue = y+14;
xLabel = x;
yLabel = y;
attrValue = LEFT | NO_UNIT | MIDSIZE;
attrLabel = SMLSIZE;
}
else if (zone.h < 50) {
xValue = x+zone.w-NUMBERS_PADDING;
yValue = y-2;
attr = NO_UNIT;
xLabel = x+NUMBERS_PADDING;
yLabel = y+2;
attrValue = NO_UNIT | DBLSIZE;
}
else {
xValue = x+NUMBERS_PADDING;
yValue = y+16;
attr = LEFT;
xLabel = x+NUMBERS_PADDING;
yLabel = y+2;
attrValue = LEFT | DBLSIZE;
}
if (field >= MIXSRC_FIRST_TIMER && field <= MIXSRC_LAST_TIMER) {
@@ -69,7 +81,7 @@ void ValueWidget::refresh()
color = ALARM_COLOR;
}
putsMixerSource(x+NUMBERS_PADDING, y+2, field, color);
putsTimer(xValue, yValue, abs(timerState.val), attr|DBLSIZE|color);
putsTimer(xValue, yValue, abs(timerState.val), attrValue|DBLSIZE|color);
return;
}
@@ -83,8 +95,8 @@ void ValueWidget::refresh()
}
}
putsMixerSource(x+NUMBERS_PADDING, y+2, field, color);
putsChannel(xValue, yValue, field, attr|DBLSIZE|color);
putsMixerSource(xLabel, yLabel, field, attrLabel|color);
putsChannel(xValue, yValue, field, attrValue|color);
}
BaseWidgetFactory<ValueWidget> ValueWidget("Value", ValueWidget::options);