using new poller class to simplify the battery interface and downstream usages of battery. tweaked poller destructor and remove the default constructor in preference of using a unique pointer convert simulator to use a std::thread for lvgl Tick api because the SDL thread sleep was not true to time. (and is simplified the code...)
33 lines
No EOL
918 B
C++
33 lines
No EOL
918 B
C++
#include "HardwareSimulator.hpp"
|
|
#include <unistd.h>
|
|
#include "SDL2/SDL.h"
|
|
#include "display/monitor.h"
|
|
#include "indev/mouse.h"
|
|
#include "indev/mousewheel.h"
|
|
#include "indev/keyboard.h"
|
|
#include "sdl/sdl.h"
|
|
|
|
#include "SDLDisplay.hpp"
|
|
|
|
HardwareSimulator::HardwareSimulator(): HardwareAbstract(),
|
|
mTickThread([](){
|
|
while(true){
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(2));
|
|
lv_tick_inc(2); /*Tell lvgl that 2 milliseconds were elapsed*/
|
|
}})
|
|
{
|
|
mBattery = std::make_shared<BatterySimulator>();
|
|
mDisplay = SDLDisplay::getInstance();
|
|
mWifiHandler = std::make_shared<wifiHandlerSim>();
|
|
|
|
}
|
|
|
|
std::shared_ptr<BatteryInterface> HardwareSimulator::battery(){
|
|
return mBattery;
|
|
}
|
|
std::shared_ptr<DisplayAbstract> HardwareSimulator::display(){
|
|
return mDisplay;
|
|
}
|
|
std::shared_ptr<wifiHandlerInterface> HardwareSimulator::wifi(){
|
|
return mWifiHandler;
|
|
} |