OMOTE/Platformio/HAL/Targets/Simulator/HardwareSimulator.cpp
Matthew Colvin 65162049b3 convert notification driven battery to lvgl timer based polling
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...)
2023-09-09 21:47:36 -04:00

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;
}