C++ refactoring, plus low-power support, plus software-based SPI CS
I'm backlogged.
This commit is contained in:
84
DisplayDriver.h
Normal file
84
DisplayDriver.h
Normal file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Max Regan
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Task.h"
|
||||
#include "SpiDriver.h"
|
||||
#include "font.h"
|
||||
|
||||
namespace BSP {
|
||||
|
||||
class DisplayDriver : public Common::Schedule::Task {
|
||||
public:
|
||||
DisplayDriver(Common::Schedule::TaskScheduler &scheduler, SpiDriver &spi);
|
||||
|
||||
static constexpr uint8_t DISPLAY_WIDTH = 144;
|
||||
static constexpr uint8_t DISPLAY_HEIGHT = 168;
|
||||
|
||||
|
||||
/**
|
||||
* Common::Schedule::Task
|
||||
*/
|
||||
Common::ReturnCode init();
|
||||
Common::Schedule::NextTime execute() override;
|
||||
|
||||
/**
|
||||
* DisplayDriver
|
||||
*/
|
||||
void set_bit(unsigned int x, unsigned int y, uint8_t val);
|
||||
void set_byte(unsigned int x, unsigned int y, uint8_t val);
|
||||
void char_at(int *x_off, int y_off, char c, const struct font *font);
|
||||
void string_at(int x_off, int y_off, const char *string, const struct font *font);
|
||||
void refresh();
|
||||
void clear();
|
||||
|
||||
private:
|
||||
void buffer_init();
|
||||
void set_dirty(unsigned int y);
|
||||
const struct glyph *glyph_for_char(const struct font *font, char c);
|
||||
|
||||
struct display_line
|
||||
{
|
||||
uint8_t mode;
|
||||
uint8_t line;
|
||||
uint8_t data[DISPLAY_WIDTH / 8];
|
||||
};
|
||||
|
||||
struct display_buffer
|
||||
{
|
||||
struct display_line lines[DISPLAY_HEIGHT];
|
||||
uint16_t dummy;
|
||||
};
|
||||
|
||||
|
||||
Common::Schedule::TaskScheduler &m_scheduler;
|
||||
SpiDriver &m_spi;
|
||||
|
||||
struct display_buffer m_buffer;
|
||||
|
||||
bool m_is_dirty;
|
||||
uint8_t m_dirty_line_min;
|
||||
uint8_t m_dirty_line_max;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user