bitmuster angepasst
This commit is contained in:
parent
8b12507c3b
commit
5401635968
|
@ -135,6 +135,13 @@ void B15F::delay_us(uint16_t us)
|
||||||
std::this_thread::sleep_for(std::chrono::microseconds(us));
|
std::this_thread::sleep_for(std::chrono::microseconds(us));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void B15F::reverse(uint8_t& b)
|
||||||
|
{
|
||||||
|
b = (b & 0xF0) >> 4 | (b & 0x0F) << 4;
|
||||||
|
b = (b & 0xCC) >> 2 | (b & 0x33) << 2;
|
||||||
|
b = (b & 0xAA) >> 1 | (b & 0x55) << 1;
|
||||||
|
}
|
||||||
|
|
||||||
// https://stackoverflow.com/a/478960
|
// https://stackoverflow.com/a/478960
|
||||||
std::string B15F::exec(std::string cmd)
|
std::string B15F::exec(std::string cmd)
|
||||||
{
|
{
|
||||||
|
@ -197,10 +204,7 @@ bool B15F::activateSelfTestMode()
|
||||||
}
|
}
|
||||||
|
|
||||||
bool B15F::digitalWrite0(uint8_t port)
|
bool B15F::digitalWrite0(uint8_t port)
|
||||||
{
|
{
|
||||||
|
|
||||||
reverse(port);
|
|
||||||
|
|
||||||
uint8_t rq[] =
|
uint8_t rq[] =
|
||||||
{
|
{
|
||||||
RQ_DIGITAL_WRITE_0,
|
RQ_DIGITAL_WRITE_0,
|
||||||
|
@ -215,9 +219,6 @@ bool B15F::digitalWrite0(uint8_t port)
|
||||||
|
|
||||||
bool B15F::digitalWrite1(uint8_t port)
|
bool B15F::digitalWrite1(uint8_t port)
|
||||||
{
|
{
|
||||||
|
|
||||||
reverse(port);
|
|
||||||
|
|
||||||
uint8_t rq[] =
|
uint8_t rq[] =
|
||||||
{
|
{
|
||||||
RQ_DIGITAL_WRITE_1,
|
RQ_DIGITAL_WRITE_1,
|
||||||
|
@ -269,6 +270,9 @@ uint8_t B15F::readDipSwitch()
|
||||||
|
|
||||||
uint8_t aw;
|
uint8_t aw;
|
||||||
usart.receive(&aw, 0, sizeof(aw));
|
usart.receive(&aw, 0, sizeof(aw));
|
||||||
|
|
||||||
|
reverse(aw); // DIP Schalter muss invertiert werden!
|
||||||
|
|
||||||
return aw;
|
return aw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -512,10 +516,3 @@ void B15F::init()
|
||||||
std::cout << PRE << "AVR Firmware Version: " << info[0] << " um " << info[1] << " Uhr (" << info[2] << ")"
|
std::cout << PRE << "AVR Firmware Version: " << info[0] << " um " << info[1] << " Uhr (" << info[2] << ")"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void B15F::reverse(uint8_t& b)
|
|
||||||
{
|
|
||||||
b = (b & 0xF0) >> 4 | (b & 0x0F) << 4;
|
|
||||||
b = (b & 0xCC) >> 2 | (b & 0x33) << 2;
|
|
||||||
b = (b & 0xAA) >> 1 | (b & 0x55) << 1;
|
|
||||||
}
|
|
||||||
|
|
|
@ -85,6 +85,13 @@ public:
|
||||||
* \param us Verzögerung in Microsekunden
|
* \param us Verzögerung in Microsekunden
|
||||||
*/
|
*/
|
||||||
void delay_us(uint16_t us);
|
void delay_us(uint16_t us);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invertiert das Bitmuster eines Bytes
|
||||||
|
* z.B.: 10100001 --> 10000101
|
||||||
|
* \param b Byte, das invertiert wird
|
||||||
|
*/
|
||||||
|
void reverse(uint8_t& b);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Führt ein Befehl auf dieser Maschine aus und liefert stdout zurück
|
* Führt ein Befehl auf dieser Maschine aus und liefert stdout zurück
|
||||||
|
@ -255,12 +262,6 @@ private:
|
||||||
* \throws DriverException
|
* \throws DriverException
|
||||||
*/
|
*/
|
||||||
void init(void);
|
void init(void);
|
||||||
|
|
||||||
/**
|
|
||||||
* Invertiert das Bitmuster eines Bytes
|
|
||||||
* z.B.: 10100001 --> 10000101
|
|
||||||
*/
|
|
||||||
void reverse(uint8_t& b);
|
|
||||||
|
|
||||||
USART usart;
|
USART usart;
|
||||||
static B15F* instance;
|
static B15F* instance;
|
||||||
|
|
|
@ -72,7 +72,7 @@ void show_info(int)
|
||||||
{
|
{
|
||||||
ViewInfo* view = new ViewInfo();
|
ViewInfo* view = new ViewInfo();
|
||||||
view->setTitle("Info");
|
view->setTitle("Info");
|
||||||
view->setText("Informationen zu Board 15 Famulus Edition\n\nProjektseite: https://github.com/devfix/b15f\nDokumentation: https://devfix.github.io/b15f/");
|
view->setText("Informationen zu Board 15 Famulus Edition\n \nProjektseite: https://github.com/devfix/b15f/\nDokumentation: https://devfix.github.io/b15f/\n \nB15F Software entwickelt von Tristan Krause für das Hardware-Labor.\nKontakt: tristan.krause@stud.htwk-leipzig.de");
|
||||||
view->setLabelClose("[ Zurueck ]");
|
view->setLabelClose("[ Zurueck ]");
|
||||||
view->repaint();
|
view->repaint();
|
||||||
|
|
||||||
|
|
|
@ -43,8 +43,11 @@ call_t ViewMonitor::keypress(int& key)
|
||||||
|
|
||||||
std::string ViewMonitor::fancyDigitalString(uint8_t& b)
|
std::string ViewMonitor::fancyDigitalString(uint8_t& b)
|
||||||
{
|
{
|
||||||
|
std::string bitstring(std::bitset<8>(b).to_string());
|
||||||
|
std::reverse(bitstring.begin(), bitstring.end());
|
||||||
|
|
||||||
std::stringstream str;
|
std::stringstream str;
|
||||||
str << std::bitset<8>(b).to_string();
|
str << bitstring;
|
||||||
str << " ";
|
str << " ";
|
||||||
str << "0x" << std::setfill ('0') << std::setw(2) << std::hex << (int) b << std::dec;
|
str << "0x" << std::setfill ('0') << std::setw(2) << std::hex << (int) b << std::dec;
|
||||||
return str.str();
|
return str.str();
|
||||||
|
@ -131,7 +134,7 @@ void ViewMonitor::worker()
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
B15F::abort("yoho meine dudes");
|
B15F::abort("Die Verbindung ist unterbrochen worden. Wurde ein Stecker gezogen? :D");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue