1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
/***************************************************************************
* Copyright (C) 2007 Nicolas Hadacek <[email protected]> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#include "tbl_bootloader_ui.h"
#include "progs/tbl_bootloader/base/tbl_bootloader.h"
#include "common/port/serial.h"
//-----------------------------------------------------------------------------
TinyBootloader::ConfigWidget::ConfigWidget(const::Programmer::Group &group, TQWidget *parent)
: ::Programmer::ConfigWidget(group, parent)
{
uint row = numRows();
TQLabel *label = new TQLabel(i18n("Port Speed:"), this);
addWidget(label, row,row, 0,0);
_speed = new KComboBox(this);
for (uint i=0; i<Port::Serial::Nb_Speeds; i++) {
if ( Port::Serial::SPEED_VALUES[i]==0 || !Port::Serial::SPEED_DATA[i].supported ) continue;
_speed->insertItem(TQString::number(Port::Serial::SPEED_VALUES[i]));
}
addWidget(_speed, row,row, 1,1);
row++;
label = new TQLabel(i18n("Timeout (ms):"), this);
addWidget(label, row,row, 0,0);
_timeout = new KIntNumInput(this);
_timeout->setMinValue(0);
addWidget(_timeout, row,row, 1,1);
row++;
label = new TQLabel(i18n("No of Retries:"), this);
addWidget(label, row,row, 0,0);
_retries = new KIntNumInput(this);
_retries->setMinValue(0);
addWidget(_retries, row,row, 1,1);
row++;
}
void TinyBootloader::ConfigWidget::saveConfig()
{
Config config;
uint k = 0;
for (uint i=0; i<Port::Serial::Nb_Speeds; i++) {
if ( Port::Serial::SPEED_VALUES[i]==0 || !Port::Serial::SPEED_DATA[i].supported ) continue;
if ( uint(_speed->currentItem())==k ) {
config.writeSpeed(Port::Serial::Speed(i));
break;
}
k++;
}
config.writeTimeout(_timeout->value());
config.writeRetries(_retries->value());
}
void TinyBootloader::ConfigWidget::loadConfig()
{
Config config;
Port::Serial::Speed speed = config.readSpeed();
uint k = 0;
for (uint i=0; i<Port::Serial::Nb_Speeds; i++) {
if ( Port::Serial::SPEED_VALUES[i]==0 || !Port::Serial::SPEED_DATA[i].supported ) continue;
if ( i==uint(speed) ) break;
k++;
}
_speed->setCurrentItem(k);
_timeout->setValue(config.readTimeout());
_retries->setValue(config.readRetries());
}
//-----------------------------------------------------------------------------
::Programmer::ConfigWidget *TinyBootloader::GroupUI::createConfigWidget(TQWidget *parent) const
{
return new ConfigWidget(static_cast<const ::Programmer::Group &>(group()), parent);
}
|