Compare commits
3 Commits
7a8e4f6096
...
f09c4700ba
| Author | SHA1 | Date | |
|---|---|---|---|
| f09c4700ba | |||
| bd87b1c074 | |||
| 753783bc3a |
@@ -1,12 +1,14 @@
|
||||
#include "Image.hpp"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace frame
|
||||
{
|
||||
|
||||
Image::Image(uint32_t pWidth, uint32_t pHeight)
|
||||
: mWidth(pWidth)
|
||||
, mHeight(pHeight)
|
||||
, mBuffer(mWidth * mHeight)
|
||||
, mBuffer(mWidth * mHeight, 0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -25,7 +27,7 @@ namespace frame
|
||||
return mBuffer.at(toInternal(x, y));
|
||||
}
|
||||
|
||||
uint8_t Image::toInternal(uint32_t x, uint32_t y) const
|
||||
size_t Image::toInternal(uint32_t x, uint32_t y) const
|
||||
{
|
||||
return x + mWidth * y;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include "Size.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
namespace frame
|
||||
@@ -29,7 +30,7 @@ namespace frame
|
||||
}
|
||||
|
||||
private:
|
||||
uint8_t toInternal(uint32_t x, uint32_t y) const;
|
||||
size_t toInternal(uint32_t x, uint32_t y) const;
|
||||
};
|
||||
|
||||
} // namespace frame
|
||||
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace frame
|
||||
{
|
||||
struct Size
|
||||
|
||||
@@ -19,6 +19,9 @@ namespace frame::display
|
||||
|
||||
bool EPD_7in5_V2::Init()
|
||||
{
|
||||
if(DEV_Module_Init()!=0)
|
||||
return false;
|
||||
|
||||
return EPD_7IN5_V2_Init() == 0;
|
||||
}
|
||||
|
||||
@@ -26,17 +29,17 @@ namespace frame::display
|
||||
{
|
||||
if(color == Color::WHITE)
|
||||
{
|
||||
EPD_7IN5_V2_Clear()
|
||||
EPD_7IN5_V2_Clear();
|
||||
} else
|
||||
{
|
||||
EPD_7IN5_V2_ClearBlack();
|
||||
}
|
||||
}
|
||||
|
||||
void EPD_7in5_V2::Display(Image const& image)
|
||||
void EPD_7in5_V2::Display(Image const& image, bool invert)
|
||||
{
|
||||
constexpr auto bytes_width = mWidth / 8;
|
||||
std::vector<uint8_t> data(bytes_with * mHeight);
|
||||
std::vector<uint8_t> data(bytes_width * mHeight);
|
||||
|
||||
uint8_t bit_counter;
|
||||
|
||||
@@ -44,15 +47,17 @@ namespace frame::display
|
||||
{
|
||||
for(auto x = 0; x < bytes_width; ++x)
|
||||
{
|
||||
uint8_t byte = 0;
|
||||
uint8_t byte = 0xFF;
|
||||
for(auto bit = 0; bit < 8; ++bit)
|
||||
{
|
||||
byte <<= 1;
|
||||
|
||||
if(image.at(x * 8 + bit, y) > 265 / 2)
|
||||
{
|
||||
byte ^= 1;
|
||||
}
|
||||
byte << 1;
|
||||
}
|
||||
byte = ~ byte;
|
||||
|
||||
data[bytes_width * y + x] = byte;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace frame::display
|
||||
|
||||
void Clear(Color color) override;
|
||||
|
||||
void Display(Image const& image) override;
|
||||
void Display(Image const& image, bool invert = false) override;
|
||||
|
||||
void Sleep() override;
|
||||
};
|
||||
|
||||
@@ -22,14 +22,14 @@ namespace frame::display
|
||||
|
||||
virtual void Clear(Color color) = 0;
|
||||
|
||||
virtual void Display(Image const& image) = 0;
|
||||
virtual void Display(Image const& image, bool invert = false) = 0;
|
||||
|
||||
virtual void Sleep() = 0;
|
||||
|
||||
public:
|
||||
Size const& getSize()
|
||||
{
|
||||
return size;
|
||||
return mSize;
|
||||
}
|
||||
};
|
||||
} // namespace frame::display
|
||||
@@ -24,12 +24,28 @@ int main()
|
||||
|
||||
frame::Image image(display.getSize());
|
||||
|
||||
for(int y = 0; y < 1; ++y)
|
||||
{
|
||||
for(int x = 0; x < image.getWidth(); ++x)
|
||||
{
|
||||
image.at(x, 0) = 0xFF;
|
||||
image.at(x, y) = 0xFF;
|
||||
}
|
||||
}
|
||||
|
||||
for(int y = image.getHeight() - 1; y < image.getHeight(); ++y)
|
||||
{
|
||||
for(int x = 0; x < image.getWidth(); ++x)
|
||||
{
|
||||
image.at(x, y) = 0xFF;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
display.Display(image);
|
||||
|
||||
std::this_thread::sleep_for(10s);
|
||||
|
||||
display.Clear(frame::display::Color::WHITE);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
47
waveshare/include/Debug.h
Normal file
47
waveshare/include/Debug.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/*****************************************************************************
|
||||
* | File : Debug.h
|
||||
* | Author : Waveshare team
|
||||
* | Function : debug with printf
|
||||
* | Info :
|
||||
* Image scanning
|
||||
* Please use progressive scanning to generate images or fonts
|
||||
*----------------
|
||||
* | This version: V2.0
|
||||
* | Date : 2018-10-30
|
||||
* | Info :
|
||||
* 1.USE_DEBUG -> DEBUG, If you need to see the debug information,
|
||||
* clear the execution: make DEBUG=-DDEBUG
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documnetation 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
|
||||
# furished 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 OR 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.
|
||||
#
|
||||
|
||||
******************************************************************************/
|
||||
#ifndef __DEBUG_H
|
||||
#define __DEBUG_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if DEBUG
|
||||
#define Debug(__info,...) printf("Debug: " __info,##__VA_ARGS__)
|
||||
#else
|
||||
#define Debug(__info,...)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user