Compare commits

...

3 Commits

Author SHA1 Message Date
f09c4700ba Fix 2022-03-02 23:54:26 +01:00
bd87b1c074 Merge branch 'bcm' of http://git.kaon-null.de/Kaonnull/Frame into bcm 2022-03-02 22:20:00 +01:00
753783bc3a WaveShare 2022-03-02 22:18:15 +01:00
9 changed files with 91 additions and 18 deletions

View File

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

View File

@@ -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
} // namespace frame

View File

@@ -1,5 +1,7 @@
#pragma once
#include <cstdint>
namespace frame
{
struct Size

View File

@@ -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;
}
@@ -66,4 +71,4 @@ namespace frame::display
EPD_7IN5_V2_Sleep();
}
} // namespace frame::display
} // namespace frame::display

View File

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

View File

@@ -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
} // namespace frame::display

View File

@@ -24,12 +24,28 @@ int main()
frame::Image image(display.getSize());
for(int x = 0; x < image.getWidth(); ++x)
for(int y = 0; y < 1; ++y)
{
image.at(x, 0) = 0xFF;
for(int x = 0; x < image.getWidth(); ++x)
{
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);
}
/*
@@ -73,4 +89,4 @@ int main()
return 0;
}
*/
*/

View File

@@ -10,4 +10,4 @@ set(src
add_library(${target} STATIC ${src})
target_include_directories(${target} PUBLIC include/)
target_link_libraries(${target} PUBLIC bcm2835)
target_link_libraries(${target} PUBLIC bcm2835)

47
waveshare/include/Debug.h Normal file
View 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