Move LCD display object to portapack namespace.

Globals are bad... Except in embedded development!
This commit is contained in:
Jared Boone
2015-08-01 14:31:51 -07:00
parent fecbb7205e
commit 65d5f68bfb
9 changed files with 26 additions and 29 deletions

View File

@@ -486,7 +486,7 @@ int main(void) {
portapack::io.init();
ui::Context context;
context.display.init();
portapack::display.init();
sdcStart(&SDCD1, nullptr);
@@ -503,7 +503,7 @@ int main(void) {
context,
{ 0, 0, 240, 320 }
};
ui::Painter painter { context.display };
ui::Painter painter;
EventDispatcher event_dispatcher { &system_view, painter, context };
context.message_map[Message::ID::FSKPacket] = [](const Message* const p) {

View File

@@ -48,6 +48,8 @@ portapack::IO io {
portapack::gpio_unused,
};
lcd::ILI9341 display;
I2C i2c0(&I2CD0);
SPI ssp0(&SPID1);
SPI ssp1(&SPID2);

View File

@@ -25,6 +25,7 @@
#include "spi_pp.hpp"
#include "wm8731.hpp"
#include "lcd_ili9341.hpp"
#include "radio.hpp"
@@ -32,6 +33,8 @@ namespace portapack {
extern portapack::IO io;
extern lcd::ILI9341 display;
extern SPI ssp0;
extern SPI ssp1;

View File

@@ -21,6 +21,9 @@
#include "ui_console.hpp"
#include "portapack.hpp"
using namespace portapack;
namespace ui {
void Console::write(const std::string message) {

View File

@@ -26,8 +26,6 @@
#include "ui_painter.hpp"
#include "ui_widget.hpp"
#include "lcd_ili9341.hpp"
#include <string>
namespace ui {
@@ -35,10 +33,8 @@ namespace ui {
class Console : public Widget {
public:
constexpr Console(
const Rect parent_rect,
lcd::ILI9341& display
) : Widget { parent_rect },
display(display)
const Rect parent_rect
) : Widget { parent_rect }
{
}
@@ -52,7 +48,6 @@ private:
static constexpr Color foreground { Color::white() };
Point pos { 0, 0 };
lcd::ILI9341& display;
void crlf();
};

View File

@@ -26,7 +26,9 @@
#include "ui_widget.hpp"
#include "spectrum_color_lut.hpp"
#include "lcd_ili9341.hpp"
#include "portapack.hpp"
using namespace portapack;
#include "message.hpp"
#include <cstdint>
@@ -180,14 +182,14 @@ class WaterfallView : public Widget {
public:
void on_show() override {
const auto screen_r = screen_rect();
context().display.scroll_set_area(screen_r.top(), screen_r.bottom());
display.scroll_set_area(screen_r.top(), screen_r.bottom());
}
void on_hide() override {
/* TODO: Clear region to eliminate brief flash of content at un-shifted
* position?
*/
context().display.scroll_disable();
display.scroll_disable();
}
void paint(Painter& painter) override {
@@ -212,7 +214,6 @@ public:
pixel_row[i] = pixel_color;
}
auto& display = context().display;
const auto draw_y = display.scroll(1);
display.draw_pixels(