Backlight: Add abstraction for support of different hardware.

This commit is contained in:
Jared Boone
2017-07-18 21:29:32 -07:00
parent e695d496c5
commit aa189a3462
7 changed files with 240 additions and 5 deletions

View File

@@ -116,6 +116,7 @@ set(CPPSRC
${COMMON}/message_queue.cpp
${COMMON}/hackrf_hal.cpp
portapack.cpp
${COMMON}/backlight.cpp
${COMMON}/portapack_shared_memory.cpp
baseband_api.cpp
${COMMON}/portapack_persistent_memory.cpp

View File

@@ -123,11 +123,12 @@ void EventDispatcher::set_display_sleep(const bool sleep) {
// TODO: Distribute display sleep message more broadly, shut down data generation
// on baseband side, since all that data is being discarded during sleep.
if( sleep ) {
portapack::io.lcd_backlight(false);
portapack::backlight()->off();
portapack::display.sleep();
} else {
portapack::display.wake();
portapack::io.lcd_backlight(true);
// Don't turn on backlight here.
// Let frame sync handler turn on backlight after repaint.
}
display_sleep = sleep;
};
@@ -268,6 +269,8 @@ void EventDispatcher::handle_lcd_frame_sync() {
DisplayFrameSyncMessage message;
message_map.send(&message);
painter.paint_widget_tree(top_widget);
portapack::backlight()->on();
}
void EventDispatcher::handle_switches() {

View File

@@ -31,6 +31,7 @@ using namespace hackrf::one;
#include "clock_manager.hpp"
#include "backlight.hpp"
#include "touch_adc.hpp"
#include "audio.hpp"
@@ -56,6 +57,9 @@ portapack::IO io {
portapack::gpio_unused,
};
portapack::BacklightCAT4004 backlight_cat4004;
portapack::BacklightOnOff backlight_on_off;
lcd::ILI9341 display;
I2C i2c0(&I2CD0);
@@ -147,6 +151,12 @@ static const portapack::cpld::Config& portapack_cpld_config() {
;
}
Backlight* backlight() {
return (portapack_model() == PortaPackModel::R2_20170522)
? static_cast<portapack::Backlight*>(&backlight_cat4004)
: static_cast<portapack::Backlight*>(&backlight_on_off);
}
static void shutdown_base() {
clock_manager.shutdown();
@@ -272,6 +282,7 @@ bool init() {
void shutdown() {
gpdma::controller.disable();
backlight()->off();
display.shutdown();
radio::disable();

View File

@@ -29,6 +29,7 @@
#include "spi_pp.hpp"
#include "si5351.hpp"
#include "lcd_ili9341.hpp"
#include "backlight.hpp"
#include "radio.hpp"
#include "clock_manager.hpp"
@@ -53,4 +54,6 @@ extern TemperatureLogger temperature_logger;
bool init();
void shutdown();
Backlight* backlight();
} /* namespace portapack */