Compare commits
9 Commits
4987702f4e
...
02562095d8
| Author | SHA1 | Date | |
|---|---|---|---|
| 02562095d8 | |||
| f09c4700ba | |||
| bd87b1c074 | |||
| 753783bc3a | |||
|
7a8e4f6096
|
|||
|
a9bdbca571
|
|||
|
1aa27e6f96
|
|||
|
afc4244f9d
|
|||
|
183e9cf80c
|
73
.clang-format
Normal file
73
.clang-format
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
---
|
||||||
|
AccessModifierOffset: '-4'
|
||||||
|
AlignAfterOpenBracket: Align
|
||||||
|
AlignConsecutiveMacros: 'true'
|
||||||
|
AlignConsecutiveAssignments: 'true'
|
||||||
|
AlignConsecutiveDeclarations: 'false'
|
||||||
|
AlignEscapedNewlines: Left
|
||||||
|
AlignOperands: 'true'
|
||||||
|
AlignTrailingComments: 'true'
|
||||||
|
AllowAllArgumentsOnNextLine: 'false'
|
||||||
|
AllowAllConstructorInitializersOnNextLine: 'false'
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: 'false'
|
||||||
|
AllowShortBlocksOnASingleLine: 'false'
|
||||||
|
AllowShortCaseLabelsOnASingleLine: 'true'
|
||||||
|
AllowShortFunctionsOnASingleLine: Empty
|
||||||
|
AllowShortIfStatementsOnASingleLine: Never
|
||||||
|
AllowShortLambdasOnASingleLine: All
|
||||||
|
AllowShortLoopsOnASingleLine: 'false'
|
||||||
|
AlwaysBreakAfterReturnType: None
|
||||||
|
AlwaysBreakBeforeMultilineStrings: 'false'
|
||||||
|
AlwaysBreakTemplateDeclarations: 'Yes'
|
||||||
|
BinPackArguments: 'false'
|
||||||
|
BinPackParameters: 'false'
|
||||||
|
BreakBeforeBinaryOperators: NonAssignment
|
||||||
|
BreakBeforeTernaryOperators: 'true'
|
||||||
|
BreakConstructorInitializers: BeforeComma
|
||||||
|
BreakInheritanceList: BeforeComma
|
||||||
|
BreakStringLiterals: 'true'
|
||||||
|
CompactNamespaces: 'false'
|
||||||
|
ContinuationIndentWidth: '4'
|
||||||
|
Cpp11BracedListStyle: 'true'
|
||||||
|
FixNamespaceComments: 'true'
|
||||||
|
IncludeBlocks: Regroup
|
||||||
|
IndentCaseLabels: 'true'
|
||||||
|
IndentPPDirectives: AfterHash
|
||||||
|
IndentWidth: '4'
|
||||||
|
IndentWrappedFunctionNames: 'true'
|
||||||
|
Language: Cpp
|
||||||
|
MaxEmptyLinesToKeep: '1'
|
||||||
|
NamespaceIndentation: All
|
||||||
|
PointerAlignment: Left
|
||||||
|
ReflowComments: 'true'
|
||||||
|
SortUsingDeclarations: 'true'
|
||||||
|
SpaceAfterCStyleCast: 'false'
|
||||||
|
SpaceAfterLogicalNot: 'false'
|
||||||
|
SpaceAfterTemplateKeyword: 'false'
|
||||||
|
SpaceBeforeAssignmentOperators: 'true'
|
||||||
|
SpaceBeforeCpp11BracedList: 'false'
|
||||||
|
SpaceBeforeCtorInitializerColon: 'true'
|
||||||
|
SpaceBeforeInheritanceColon: 'true'
|
||||||
|
SpaceBeforeParens: Never
|
||||||
|
SpaceBeforeRangeBasedForLoopColon: 'true'
|
||||||
|
SpaceInEmptyParentheses: 'false'
|
||||||
|
SpacesInAngles: 'false'
|
||||||
|
SpacesInCStyleCastParentheses: 'false'
|
||||||
|
SpacesInContainerLiterals: 'false'
|
||||||
|
SpacesInSquareBrackets: 'false'
|
||||||
|
Standard: Auto
|
||||||
|
|
||||||
|
BreakBeforeBraces: Custom
|
||||||
|
BraceWrapping:
|
||||||
|
AfterClass: true
|
||||||
|
AfterStruct: true
|
||||||
|
BeforeCatch: true
|
||||||
|
AfterControlStatement: "Always"
|
||||||
|
AfterFunction: true
|
||||||
|
AfterNamespace: true
|
||||||
|
AfterUnion: true
|
||||||
|
SplitEmptyFunction: true
|
||||||
|
SplitEmptyNamespace: true
|
||||||
|
SplitEmptyRecord: true
|
||||||
|
|
||||||
|
|
||||||
36
.gitignore
vendored
36
.gitignore
vendored
@@ -32,37 +32,5 @@
|
|||||||
*.out
|
*.out
|
||||||
*.app
|
*.app
|
||||||
|
|
||||||
build/.ninja_deps
|
build/*
|
||||||
build/.ninja_log
|
.vscode/*
|
||||||
build/build.ninja
|
|
||||||
build/cmake_install.cmake
|
|
||||||
build/CMakeCache.txt
|
|
||||||
build/compile_commands.json
|
|
||||||
build/.cmake/api/v1/query/client-vscode/query.json
|
|
||||||
build/.cmake/api/v1/reply/cache-v2-8e3d784e6607879cd18c.json
|
|
||||||
build/.cmake/api/v1/reply/codemodel-v2-97bfd906ef366d86b34b.json
|
|
||||||
build/.cmake/api/v1/reply/index-2022-02-11T18-35-30-0824.json
|
|
||||||
build/.cmake/api/v1/reply/target-frame-Debug-7d0b6524a58d8e907a2f.json
|
|
||||||
build/.cmake/api/v1/reply/toolchains-v1-65972111b21e4388dc41.json
|
|
||||||
build/CMakeFiles/cmake.check_cache
|
|
||||||
build/CMakeFiles/CMakeOutput.log
|
|
||||||
build/CMakeFiles/rules.ninja
|
|
||||||
build/CMakeFiles/TargetDirectories.txt
|
|
||||||
build/CMakeFiles/3.20.21032501-MSVC_2/CMakeCCompiler.cmake
|
|
||||||
build/CMakeFiles/3.20.21032501-MSVC_2/CMakeCXXCompiler.cmake
|
|
||||||
build/CMakeFiles/3.20.21032501-MSVC_2/CMakeDetermineCompilerABI_C.bin
|
|
||||||
build/CMakeFiles/3.20.21032501-MSVC_2/CMakeDetermineCompilerABI_CXX.bin
|
|
||||||
build/CMakeFiles/3.20.21032501-MSVC_2/CMakeRCCompiler.cmake
|
|
||||||
build/CMakeFiles/3.20.21032501-MSVC_2/CMakeSystem.cmake
|
|
||||||
build/CMakeFiles/3.20.21032501-MSVC_2/CompilerIdC/CMakeCCompilerId.c
|
|
||||||
build/CMakeFiles/3.20.21032501-MSVC_2/CompilerIdCXX/CMakeCXXCompilerId.cpp
|
|
||||||
build/CMakeFiles/ShowIncludes/foo.h
|
|
||||||
build/CMakeFiles/ShowIncludes/main.c
|
|
||||||
build/frame/cmake_install.cmake
|
|
||||||
build/frame/frame.ilk
|
|
||||||
build/frame/frame.pdb
|
|
||||||
build/frame/CMakeFiles/frame.dir/embed.manifest
|
|
||||||
build/frame/CMakeFiles/frame.dir/intermediate.manifest
|
|
||||||
build/frame/CMakeFiles/frame.dir/manifest.rc
|
|
||||||
build/frame/CMakeFiles/frame.dir/manifest.res
|
|
||||||
build/frame/CMakeFiles/frame.dir/vc140.pdb
|
|
||||||
|
|||||||
@@ -5,4 +5,11 @@ project(Frame)
|
|||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
|
|
||||||
|
#if (UNIX)
|
||||||
|
add_subdirectory(bcm2835)
|
||||||
|
add_subdirectory(waveshare)
|
||||||
|
#endif (UNIX)
|
||||||
|
|
||||||
add_subdirectory(frame)
|
add_subdirectory(frame)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
4
bcm2835/CMakeLists.txt
Normal file
4
bcm2835/CMakeLists.txt
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
|
||||||
|
add_library(bcm2835 STATIC include/bcm2835.h src/bcm2835.c)
|
||||||
|
target_include_directories(bcm2835 PUBLIC include/)
|
||||||
2188
bcm2835/include/bcm2835.h
Normal file
2188
bcm2835/include/bcm2835.h
Normal file
File diff suppressed because it is too large
Load Diff
2243
bcm2835/src/bcm2835.c
Normal file
2243
bcm2835/src/bcm2835.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,14 @@
|
|||||||
|
|
||||||
set(target frame)
|
set(target frame)
|
||||||
|
|
||||||
|
set(src
|
||||||
|
src/main.cpp
|
||||||
|
src/Image.hpp
|
||||||
|
src/Image.cpp
|
||||||
|
src/display/IDisplay.hpp
|
||||||
|
src/display/EPD_7in5_V2.hpp
|
||||||
|
src/display/EPD_7in5_V2.cpp
|
||||||
|
)
|
||||||
|
|
||||||
add_executable(${target} main.cpp)
|
add_executable(${target} ${src})
|
||||||
|
target_link_libraries(${target} PRIVATE waveshare)
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
#include <iostream>
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
std::cout << "Hallo Welt" << std::endl;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
35
frame/src/Image.cpp
Normal file
35
frame/src/Image.cpp
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
#include "Image.hpp"
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
namespace frame
|
||||||
|
{
|
||||||
|
|
||||||
|
Image::Image(uint32_t pWidth, uint32_t pHeight)
|
||||||
|
: mWidth(pWidth)
|
||||||
|
, mHeight(pHeight)
|
||||||
|
, mBuffer(mWidth * mHeight, 0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Image::Image(Size size)
|
||||||
|
: Image(size.width, size.height)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t& Image::at(uint32_t x, uint32_t y)
|
||||||
|
{
|
||||||
|
return mBuffer.at(toInternal(x, y));
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t const& Image::at(uint32_t x, uint32_t y) const
|
||||||
|
{
|
||||||
|
return mBuffer.at(toInternal(x, y));
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t Image::toInternal(uint32_t x, uint32_t y) const
|
||||||
|
{
|
||||||
|
return x + mWidth * y;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace frame
|
||||||
36
frame/src/Image.hpp
Normal file
36
frame/src/Image.hpp
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Size.hpp"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace frame
|
||||||
|
{
|
||||||
|
|
||||||
|
class Image
|
||||||
|
{
|
||||||
|
uint32_t mWidth;
|
||||||
|
uint32_t mHeight;
|
||||||
|
std::vector<uint8_t> mBuffer;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Image(uint32_t pWidth, uint32_t pHeight);
|
||||||
|
Image(Size size);
|
||||||
|
|
||||||
|
uint8_t& at(uint32_t x, uint32_t y);
|
||||||
|
uint8_t const& at(uint32_t x, uint32_t y) const;
|
||||||
|
|
||||||
|
auto getWidth() const
|
||||||
|
{
|
||||||
|
return mWidth;
|
||||||
|
}
|
||||||
|
auto getHeight() const
|
||||||
|
{
|
||||||
|
return mHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
size_t toInternal(uint32_t x, uint32_t y) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace frame
|
||||||
12
frame/src/Size.hpp
Normal file
12
frame/src/Size.hpp
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace frame
|
||||||
|
{
|
||||||
|
struct Size
|
||||||
|
{
|
||||||
|
uint32_t width;
|
||||||
|
uint32_t height;
|
||||||
|
};
|
||||||
|
} // namespace frame
|
||||||
74
frame/src/display/EPD_7in5_V2.cpp
Normal file
74
frame/src/display/EPD_7in5_V2.cpp
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
#include "EPD_7in5_V2.hpp"
|
||||||
|
|
||||||
|
#include <EPD_7in5_V2.h>
|
||||||
|
|
||||||
|
namespace frame::display
|
||||||
|
{
|
||||||
|
constexpr uint32_t mWidth = EPD_7IN5_V2_WIDTH;
|
||||||
|
constexpr uint32_t mHeight = EPD_7IN5_V2_HEIGHT;
|
||||||
|
|
||||||
|
EPD_7in5_V2::EPD_7in5_V2()
|
||||||
|
: IDisplay("EPD_7in5_V2", {mWidth, mHeight})
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
EPD_7in5_V2::~EPD_7in5_V2()
|
||||||
|
{
|
||||||
|
Sleep();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EPD_7in5_V2::Init()
|
||||||
|
{
|
||||||
|
if(DEV_Module_Init()!=0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return EPD_7IN5_V2_Init() == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EPD_7in5_V2::Clear(Color color)
|
||||||
|
{
|
||||||
|
if(color == Color::WHITE)
|
||||||
|
{
|
||||||
|
EPD_7IN5_V2_Clear();
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
EPD_7IN5_V2_ClearBlack();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EPD_7in5_V2::Display(Image const& image, bool invert)
|
||||||
|
{
|
||||||
|
constexpr auto bytes_width = mWidth / 8;
|
||||||
|
std::vector<uint8_t> data(bytes_width * mHeight);
|
||||||
|
|
||||||
|
uint8_t bit_counter;
|
||||||
|
|
||||||
|
for(auto y = 0; y < mHeight; ++y)
|
||||||
|
{
|
||||||
|
for(auto x = 0; x < bytes_width; ++x)
|
||||||
|
{
|
||||||
|
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 = ~ byte;
|
||||||
|
|
||||||
|
data[bytes_width * y + x] = byte;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EPD_7IN5_V2_Display(data.data());
|
||||||
|
}
|
||||||
|
|
||||||
|
void EPD_7in5_V2::Sleep()
|
||||||
|
{
|
||||||
|
EPD_7IN5_V2_Sleep();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace frame::display
|
||||||
23
frame/src/display/EPD_7in5_V2.hpp
Normal file
23
frame/src/display/EPD_7in5_V2.hpp
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "IDisplay.hpp"
|
||||||
|
|
||||||
|
namespace frame::display
|
||||||
|
{
|
||||||
|
|
||||||
|
class EPD_7in5_V2 : public IDisplay
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
EPD_7in5_V2();
|
||||||
|
~EPD_7in5_V2();
|
||||||
|
|
||||||
|
bool Init() override;
|
||||||
|
|
||||||
|
void Clear(Color color) override;
|
||||||
|
|
||||||
|
void Display(Image const& image, bool invert = false) override;
|
||||||
|
|
||||||
|
void Sleep() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace frame::display
|
||||||
35
frame/src/display/IDisplay.hpp
Normal file
35
frame/src/display/IDisplay.hpp
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "../Image.hpp"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace frame::display
|
||||||
|
{
|
||||||
|
enum class Color { WHITE, BLACK };
|
||||||
|
|
||||||
|
class IDisplay
|
||||||
|
{
|
||||||
|
std::string mName;
|
||||||
|
Size mSize;
|
||||||
|
|
||||||
|
public:
|
||||||
|
IDisplay(std::string_view pName, Size pSize)
|
||||||
|
: mName(pName)
|
||||||
|
, mSize(pSize){};
|
||||||
|
virtual ~IDisplay() = default;
|
||||||
|
|
||||||
|
virtual bool Init() = 0;
|
||||||
|
|
||||||
|
virtual void Clear(Color color) = 0;
|
||||||
|
|
||||||
|
virtual void Display(Image const& image, bool invert = false) = 0;
|
||||||
|
|
||||||
|
virtual void Sleep() = 0;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Size const& getSize()
|
||||||
|
{
|
||||||
|
return mSize;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace frame::display
|
||||||
92
frame/src/main.cpp
Normal file
92
frame/src/main.cpp
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
#include <chrono>
|
||||||
|
#include <iostream>
|
||||||
|
#include <thread>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
|
#include "display/EPD_7in5_V2.hpp"
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
|
||||||
|
frame::display::EPD_7in5_V2 display{};
|
||||||
|
|
||||||
|
display.Init();
|
||||||
|
|
||||||
|
display.Clear(frame::display::Color::BLACK);
|
||||||
|
|
||||||
|
std::this_thread::sleep_for(2s);
|
||||||
|
|
||||||
|
display.Clear(frame::display::Color::WHITE);
|
||||||
|
|
||||||
|
std::this_thread::sleep_for(2s);
|
||||||
|
|
||||||
|
frame::Image image(display.getSize());
|
||||||
|
|
||||||
|
for(int y = 0; y < 1; ++y)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
#include <EPD_7in5_V2.h>
|
||||||
|
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
std::cout << "Hallo Welt" << std::endl;
|
||||||
|
|
||||||
|
EPD_7IN5_V2_Init();
|
||||||
|
|
||||||
|
EPD_7IN5_V2_ClearBlack();
|
||||||
|
|
||||||
|
std::this_thread::sleep_for(2s);
|
||||||
|
|
||||||
|
EPD_7IN5_V2_Clear();
|
||||||
|
|
||||||
|
std::this_thread::sleep_for(2s);
|
||||||
|
|
||||||
|
std::vector<uint8_t> image;
|
||||||
|
image.resize(EPD_7IN5_V2_HEIGHT * EPD_7IN5_V2_WIDTH);
|
||||||
|
|
||||||
|
uint8_t color = 0;
|
||||||
|
for(int x = 0; x < EPD_7IN5_V2_WIDTH; ++x)
|
||||||
|
{
|
||||||
|
for(int y = 0; y < EPD_7IN5_V2_HEIGHT; ++y)
|
||||||
|
{
|
||||||
|
image[EPD_7IN5_V2_WIDTH * y + x] = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
color = ~color;
|
||||||
|
}
|
||||||
|
|
||||||
|
EPD_7IN5_V2_Display(image.data());
|
||||||
|
|
||||||
|
std::this_thread::sleep_for(10s);
|
||||||
|
|
||||||
|
EPD_7IN5_V2_Clear();
|
||||||
|
EPD_7IN5_V2_Sleep();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
*/
|
||||||
13
waveshare/CMakeLists.txt
Normal file
13
waveshare/CMakeLists.txt
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
set(target waveshare)
|
||||||
|
|
||||||
|
set(src
|
||||||
|
include/DEV_Config.h
|
||||||
|
include/EPD_7in5_V2.h
|
||||||
|
src/DEV_Config.c
|
||||||
|
src/EPD_7in5_V2.c
|
||||||
|
)
|
||||||
|
|
||||||
|
add_library(${target} STATIC ${src})
|
||||||
|
target_include_directories(${target} PUBLIC include/)
|
||||||
|
target_link_libraries(${target} PUBLIC bcm2835)
|
||||||
111
waveshare/include/DEV_Config.h
Normal file
111
waveshare/include/DEV_Config.h
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : DEV_Config.h
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : Hardware underlying interface
|
||||||
|
* | Info :
|
||||||
|
* Used to shield the underlying layers of each master
|
||||||
|
* and enhance portability
|
||||||
|
*----------------
|
||||||
|
* | This version: V2.0
|
||||||
|
* | Date : 2018-10-30
|
||||||
|
* | Info :
|
||||||
|
* 1.add:
|
||||||
|
* UBYTE\UWORD\UDOUBLE
|
||||||
|
* 2.Change:
|
||||||
|
* EPD_RST -> EPD_RST_PIN
|
||||||
|
* EPD_DC -> EPD_DC_PIN
|
||||||
|
* EPD_CS -> EPD_CS_PIN
|
||||||
|
* EPD_BUSY -> EPD_BUSY_PIN
|
||||||
|
* 3.Remote:
|
||||||
|
* EPD_RST_1\EPD_RST_0
|
||||||
|
* EPD_DC_1\EPD_DC_0
|
||||||
|
* EPD_CS_1\EPD_CS_0
|
||||||
|
* EPD_BUSY_1\EPD_BUSY_0
|
||||||
|
* 3.add:
|
||||||
|
* #define DEV_Digital_Write(_pin, _value) bcm2835_GPIOI_write(_pin, _value)
|
||||||
|
* #define DEV_Digital_Read(_pin) bcm2835_GPIOI_lev(_pin)
|
||||||
|
* #define DEV_SPI_WriteByte(__value) bcm2835_spi_transfer(__value)
|
||||||
|
#
|
||||||
|
# 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 _DEV_CONFIG_H_
|
||||||
|
#define _DEV_CONFIG_H_
|
||||||
|
|
||||||
|
#define RPI
|
||||||
|
#define USE_BCM2835_LIB
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "Debug.h"
|
||||||
|
|
||||||
|
#ifdef RPI
|
||||||
|
#ifdef USE_BCM2835_LIB
|
||||||
|
#include <bcm2835.h>
|
||||||
|
#elif USE_WIRINGPI_LIB
|
||||||
|
#include <wiringPi.h>
|
||||||
|
#include <wiringPiSPI.h>
|
||||||
|
#elif USE_DEV_LIB
|
||||||
|
#include "RPI_sysfs_gpio.h"
|
||||||
|
#include "dev_hardware_SPI.h"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef JETSON
|
||||||
|
#ifdef USE_DEV_LIB
|
||||||
|
#include "sysfs_gpio.h"
|
||||||
|
#include "sysfs_software_spi.h"
|
||||||
|
#elif USE_HARDWARE_LIB
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* data
|
||||||
|
**/
|
||||||
|
#define UBYTE uint8_t
|
||||||
|
#define UWORD uint16_t
|
||||||
|
#define UDOUBLE uint32_t
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GPIOI config
|
||||||
|
**/
|
||||||
|
extern int EPD_RST_PIN;
|
||||||
|
extern int EPD_DC_PIN;
|
||||||
|
extern int EPD_CS_PIN;
|
||||||
|
extern int EPD_BUSY_PIN;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------------------------------*/
|
||||||
|
void DEV_Digital_Write(UWORD Pin, UBYTE Value);
|
||||||
|
UBYTE DEV_Digital_Read(UWORD Pin);
|
||||||
|
|
||||||
|
void DEV_SPI_WriteByte(UBYTE Value);
|
||||||
|
void DEV_SPI_Write_nByte(uint8_t *pData, uint32_t Len);
|
||||||
|
void DEV_Delay_ms(UDOUBLE xms);
|
||||||
|
|
||||||
|
UBYTE DEV_Module_Init(void);
|
||||||
|
void DEV_Module_Exit(void);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
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
|
||||||
|
|
||||||
57
waveshare/include/EPD_7in5_V2.h
Normal file
57
waveshare/include/EPD_7in5_V2.h
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : EPD_7in5_V2.h
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : Electronic paper driver
|
||||||
|
* | Info :
|
||||||
|
*----------------
|
||||||
|
* | This version: V2.0
|
||||||
|
* | Date : 2018-11-09
|
||||||
|
* | Info :
|
||||||
|
* 1.Remove:ImageBuff[EPD_HEIGHT * EPD_WIDTH / 8]
|
||||||
|
* 2.Change:EPD_Display(UBYTE *Image)
|
||||||
|
* Need to pass parameters: pointer to cached data
|
||||||
|
#
|
||||||
|
# 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 _EPD_7IN5_V2_H_
|
||||||
|
#define _EPD_7IN5_V2_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "DEV_Config.h"
|
||||||
|
|
||||||
|
|
||||||
|
// Display resolution
|
||||||
|
#define EPD_7IN5_V2_WIDTH 800
|
||||||
|
#define EPD_7IN5_V2_HEIGHT 480
|
||||||
|
|
||||||
|
UBYTE EPD_7IN5_V2_Init(void);
|
||||||
|
void EPD_7IN5_V2_Clear(void);
|
||||||
|
void EPD_7IN5_V2_ClearBlack(void);
|
||||||
|
void EPD_7IN5_V2_Display(const UBYTE *blackimage);
|
||||||
|
void EPD_7IN5_V2_Sleep(void);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
385
waveshare/src/DEV_Config.c
Normal file
385
waveshare/src/DEV_Config.c
Normal file
@@ -0,0 +1,385 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : DEV_Config.c
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : Hardware underlying interface
|
||||||
|
* | Info :
|
||||||
|
*----------------
|
||||||
|
* | This version: V3.0
|
||||||
|
* | Date : 2019-07-31
|
||||||
|
* | Info :
|
||||||
|
#
|
||||||
|
# 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 theex 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.
|
||||||
|
#
|
||||||
|
******************************************************************************/
|
||||||
|
#include "DEV_Config.h"
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GPIO
|
||||||
|
**/
|
||||||
|
int EPD_RST_PIN;
|
||||||
|
int EPD_DC_PIN;
|
||||||
|
int EPD_CS_PIN;
|
||||||
|
int EPD_BUSY_PIN;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GPIO read and write
|
||||||
|
**/
|
||||||
|
void DEV_Digital_Write(UWORD Pin, UBYTE Value)
|
||||||
|
{
|
||||||
|
#ifdef RPI
|
||||||
|
#ifdef USE_BCM2835_LIB
|
||||||
|
bcm2835_gpio_write(Pin, Value);
|
||||||
|
#elif USE_WIRINGPI_LIB
|
||||||
|
digitalWrite(Pin, Value);
|
||||||
|
#elif USE_DEV_LIB
|
||||||
|
SYSFS_GPIO_Write(Pin, Value);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef JETSON
|
||||||
|
#ifdef USE_DEV_LIB
|
||||||
|
SYSFS_GPIO_Write(Pin, Value);
|
||||||
|
#elif USE_HARDWARE_LIB
|
||||||
|
Debug("not support");
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
UBYTE DEV_Digital_Read(UWORD Pin)
|
||||||
|
{
|
||||||
|
UBYTE Read_value = 0;
|
||||||
|
#ifdef RPI
|
||||||
|
#ifdef USE_BCM2835_LIB
|
||||||
|
Read_value = bcm2835_gpio_lev(Pin);
|
||||||
|
#elif USE_WIRINGPI_LIB
|
||||||
|
Read_value = digitalRead(Pin);
|
||||||
|
#elif USE_DEV_LIB
|
||||||
|
Read_value = SYSFS_GPIO_Read(Pin);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef JETSON
|
||||||
|
#ifdef USE_DEV_LIB
|
||||||
|
Read_value = SYSFS_GPIO_Read(Pin);
|
||||||
|
#elif USE_HARDWARE_LIB
|
||||||
|
Debug("not support");
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
return Read_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SPI
|
||||||
|
**/
|
||||||
|
void DEV_SPI_WriteByte(uint8_t Value)
|
||||||
|
{
|
||||||
|
#ifdef RPI
|
||||||
|
#ifdef USE_BCM2835_LIB
|
||||||
|
bcm2835_spi_transfer(Value);
|
||||||
|
#elif USE_WIRINGPI_LIB
|
||||||
|
wiringPiSPIDataRW(0,&Value,1);
|
||||||
|
#elif USE_DEV_LIB
|
||||||
|
DEV_HARDWARE_SPI_TransferByte(Value);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef JETSON
|
||||||
|
#ifdef USE_DEV_LIB
|
||||||
|
SYSFS_software_spi_transfer(Value);
|
||||||
|
#elif USE_HARDWARE_LIB
|
||||||
|
Debug("not support");
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void DEV_SPI_Write_nByte(uint8_t *pData, uint32_t Len)
|
||||||
|
{
|
||||||
|
#ifdef RPI
|
||||||
|
#ifdef USE_BCM2835_LIB
|
||||||
|
char rData[Len];
|
||||||
|
bcm2835_spi_transfernb((char *)pData,rData,Len);
|
||||||
|
#elif USE_WIRINGPI_LIB
|
||||||
|
wiringPiSPIDataRW(0, pData, Len);
|
||||||
|
#elif USE_DEV_LIB
|
||||||
|
DEV_HARDWARE_SPI_Transfer(pData, Len);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef JETSON
|
||||||
|
#ifdef USE_DEV_LIB
|
||||||
|
//JETSON nano waits for hardware SPI
|
||||||
|
Debug("not support");
|
||||||
|
#elif USE_HARDWARE_LIB
|
||||||
|
Debug("not support");
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GPIO Mode
|
||||||
|
**/
|
||||||
|
void DEV_GPIO_Mode(UWORD Pin, UWORD Mode)
|
||||||
|
{
|
||||||
|
#ifdef RPI
|
||||||
|
#ifdef USE_BCM2835_LIB
|
||||||
|
if(Mode == 0 || Mode == BCM2835_GPIO_FSEL_INPT) {
|
||||||
|
bcm2835_gpio_fsel(Pin, BCM2835_GPIO_FSEL_INPT);
|
||||||
|
} else {
|
||||||
|
bcm2835_gpio_fsel(Pin, BCM2835_GPIO_FSEL_OUTP);
|
||||||
|
}
|
||||||
|
#elif USE_WIRINGPI_LIB
|
||||||
|
if(Mode == 0 || Mode == INPUT) {
|
||||||
|
pinMode(Pin, INPUT);
|
||||||
|
pullUpDnControl(Pin, PUD_UP);
|
||||||
|
} else {
|
||||||
|
pinMode(Pin, OUTPUT);
|
||||||
|
// Debug (" %d OUT \r\n",Pin);
|
||||||
|
}
|
||||||
|
#elif USE_DEV_LIB
|
||||||
|
SYSFS_GPIO_Export(Pin);
|
||||||
|
if(Mode == 0 || Mode == SYSFS_GPIO_IN) {
|
||||||
|
SYSFS_GPIO_Direction(Pin, SYSFS_GPIO_IN);
|
||||||
|
// Debug("IN Pin = %d\r\n",Pin);
|
||||||
|
} else {
|
||||||
|
SYSFS_GPIO_Direction(Pin, SYSFS_GPIO_OUT);
|
||||||
|
// Debug("OUT Pin = %d\r\n",Pin);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef JETSON
|
||||||
|
#ifdef USE_DEV_LIB
|
||||||
|
SYSFS_GPIO_Export(Pin);
|
||||||
|
SYSFS_GPIO_Direction(Pin, Mode);
|
||||||
|
#elif USE_HARDWARE_LIB
|
||||||
|
Debug("not support");
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* delay x ms
|
||||||
|
**/
|
||||||
|
void DEV_Delay_ms(UDOUBLE xms)
|
||||||
|
{
|
||||||
|
#ifdef RPI
|
||||||
|
#ifdef USE_BCM2835_LIB
|
||||||
|
bcm2835_delay(xms);
|
||||||
|
#elif USE_WIRINGPI_LIB
|
||||||
|
delay(xms);
|
||||||
|
#elif USE_DEV_LIB
|
||||||
|
UDOUBLE i;
|
||||||
|
for(i=0; i < xms; i++) {
|
||||||
|
usleep(1000);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef JETSON
|
||||||
|
UDOUBLE i;
|
||||||
|
for(i=0; i < xms; i++) {
|
||||||
|
usleep(1000);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DEV_Equipment_Testing(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int fd;
|
||||||
|
char value_str[20];
|
||||||
|
fd = open("/etc/issue", O_RDONLY);
|
||||||
|
printf("Current environment: ");
|
||||||
|
while(1) {
|
||||||
|
if (fd < 0) {
|
||||||
|
Debug( "Read failed Pin\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
for(i=0;; i++) {
|
||||||
|
if (read(fd, &value_str[i], 1) < 0) {
|
||||||
|
Debug( "failed to read value!\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if(value_str[i] ==32) {
|
||||||
|
printf("\r\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
printf("%c",value_str[i]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#ifdef RPI
|
||||||
|
if(i<5) {
|
||||||
|
printf("Unrecognizable\r\n");
|
||||||
|
} else {
|
||||||
|
char RPI_System[10] = {"Raspbian"};
|
||||||
|
for(i=0; i<6; i++) {
|
||||||
|
if(RPI_System[i]!= value_str[i]) {
|
||||||
|
printf("Please make JETSON !!!!!!!!!!\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef JETSON
|
||||||
|
if(i<5) {
|
||||||
|
Debug("Unrecognizable\r\n");
|
||||||
|
} else {
|
||||||
|
char JETSON_System[10]= {"Ubuntu"};
|
||||||
|
for(i=0; i<6; i++) {
|
||||||
|
if(JETSON_System[i]!= value_str[i] ) {
|
||||||
|
printf("Please make RPI !!!!!!!!!!\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void DEV_GPIO_Init(void)
|
||||||
|
{
|
||||||
|
#ifdef RPI
|
||||||
|
EPD_RST_PIN = 17;
|
||||||
|
EPD_DC_PIN = 25;
|
||||||
|
EPD_CS_PIN = 8;
|
||||||
|
EPD_BUSY_PIN = 24;
|
||||||
|
#elif JETSON
|
||||||
|
EPD_RST_PIN = GPIO17;
|
||||||
|
EPD_DC_PIN = GPIO25;
|
||||||
|
EPD_CS_PIN = SPI0_CS0;
|
||||||
|
EPD_BUSY_PIN = GPIO24;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
DEV_GPIO_Mode(EPD_RST_PIN, 1);
|
||||||
|
DEV_GPIO_Mode(EPD_DC_PIN, 1);
|
||||||
|
DEV_GPIO_Mode(EPD_CS_PIN, 1);
|
||||||
|
DEV_GPIO_Mode(EPD_BUSY_PIN, 0);
|
||||||
|
|
||||||
|
DEV_Digital_Write(EPD_CS_PIN, 1);
|
||||||
|
}
|
||||||
|
/******************************************************************************
|
||||||
|
function: Module Initialize, the library and initialize the pins, SPI protocol
|
||||||
|
parameter:
|
||||||
|
Info:
|
||||||
|
******************************************************************************/
|
||||||
|
UBYTE DEV_Module_Init(void)
|
||||||
|
{
|
||||||
|
printf("/***********************************/ \r\n");
|
||||||
|
if(DEV_Equipment_Testing() < 0) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#ifdef RPI
|
||||||
|
#ifdef USE_BCM2835_LIB
|
||||||
|
if(!bcm2835_init()) {
|
||||||
|
printf("bcm2835 init failed !!! \r\n");
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
printf("bcm2835 init success !!! \r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// GPIO Config
|
||||||
|
DEV_GPIO_Init();
|
||||||
|
|
||||||
|
bcm2835_spi_begin(); //Start spi interface, set spi pin for the reuse function
|
||||||
|
bcm2835_spi_setBitOrder(BCM2835_SPI_BIT_ORDER_MSBFIRST); //High first transmission
|
||||||
|
bcm2835_spi_setDataMode(BCM2835_SPI_MODE0); //spi mode 0
|
||||||
|
bcm2835_spi_setClockDivider(BCM2835_SPI_CLOCK_DIVIDER_128); //Frequency
|
||||||
|
bcm2835_spi_chipSelect(BCM2835_SPI_CS0); //set CE0
|
||||||
|
bcm2835_spi_setChipSelectPolarity(BCM2835_SPI_CS0, LOW); //enable cs0
|
||||||
|
|
||||||
|
#elif USE_WIRINGPI_LIB
|
||||||
|
//if(wiringPiSetup() < 0)//use wiringpi Pin number table
|
||||||
|
if(wiringPiSetupGpio() < 0) { //use BCM2835 Pin number table
|
||||||
|
printf("set wiringPi lib failed !!! \r\n");
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
printf("set wiringPi lib success !!! \r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// GPIO Config
|
||||||
|
DEV_GPIO_Init();
|
||||||
|
wiringPiSPISetup(0,10000000);
|
||||||
|
// wiringPiSPISetupMode(0, 32000000, 0);
|
||||||
|
#elif USE_DEV_LIB
|
||||||
|
printf("Write and read /dev/spidev0.0 \r\n");
|
||||||
|
DEV_GPIO_Init();
|
||||||
|
DEV_HARDWARE_SPI_begin("/dev/spidev0.0");
|
||||||
|
DEV_HARDWARE_SPI_setSpeed(10000000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif JETSON
|
||||||
|
#ifdef USE_DEV_LIB
|
||||||
|
DEV_GPIO_Init();
|
||||||
|
printf("Software spi\r\n");
|
||||||
|
SYSFS_software_spi_begin();
|
||||||
|
SYSFS_software_spi_setBitOrder(SOFTWARE_SPI_MSBFIRST);
|
||||||
|
SYSFS_software_spi_setDataMode(SOFTWARE_SPI_Mode0);
|
||||||
|
SYSFS_software_spi_setClockDivider(SOFTWARE_SPI_CLOCK_DIV4);
|
||||||
|
#elif USE_HARDWARE_LIB
|
||||||
|
printf("Write and read /dev/spidev0.0 \r\n");
|
||||||
|
DEV_GPIO_Init();
|
||||||
|
DEV_HARDWARE_SPI_begin("/dev/spidev0.0");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
printf("/***********************************/ \r\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function: Module exits, closes SPI and BCM2835 library
|
||||||
|
parameter:
|
||||||
|
Info:
|
||||||
|
******************************************************************************/
|
||||||
|
void DEV_Module_Exit(void)
|
||||||
|
{
|
||||||
|
#ifdef RPI
|
||||||
|
#ifdef USE_BCM2835_LIB
|
||||||
|
DEV_Digital_Write(EPD_CS_PIN, LOW);
|
||||||
|
DEV_Digital_Write(EPD_DC_PIN, LOW);
|
||||||
|
DEV_Digital_Write(EPD_RST_PIN, LOW);
|
||||||
|
|
||||||
|
bcm2835_spi_end();
|
||||||
|
bcm2835_close();
|
||||||
|
#elif USE_WIRINGPI_LIB
|
||||||
|
DEV_Digital_Write(EPD_CS_PIN, 0);
|
||||||
|
DEV_Digital_Write(EPD_DC_PIN, 0);
|
||||||
|
DEV_Digital_Write(EPD_RST_PIN, 0);
|
||||||
|
#elif USE_DEV_LIB
|
||||||
|
DEV_HARDWARE_SPI_end();
|
||||||
|
DEV_Digital_Write(EPD_CS_PIN, 0);
|
||||||
|
DEV_Digital_Write(EPD_DC_PIN, 0);
|
||||||
|
DEV_Digital_Write(EPD_RST_PIN, 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif JETSON
|
||||||
|
#ifdef USE_DEV_LIB
|
||||||
|
SYSFS_GPIO_Unexport(EPD_CS_PIN);
|
||||||
|
SYSFS_GPIO_Unexport(EPD_DC_PIN);
|
||||||
|
SYSFS_GPIO_Unexport(EPD_RST_PIN);
|
||||||
|
SYSFS_GPIO_Unexport(EPD_BUSY_PIN);
|
||||||
|
#elif USE_HARDWARE_LIB
|
||||||
|
Debug("not support");
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
}
|
||||||
321
waveshare/src/EPD_7in5_V2.c
Normal file
321
waveshare/src/EPD_7in5_V2.c
Normal file
@@ -0,0 +1,321 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : EPD_7in5.c
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : Electronic paper driver
|
||||||
|
* | Info :
|
||||||
|
*----------------
|
||||||
|
* | This version: V2.0
|
||||||
|
* | Date : 2018-11-09
|
||||||
|
* | Info :
|
||||||
|
*****************************************************************************
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
******************************************************************************/
|
||||||
|
#include "EPD_7in5_V2.h"
|
||||||
|
#include "Debug.h"
|
||||||
|
|
||||||
|
|
||||||
|
UBYTE Voltage_Frame_7IN5_V2[]={
|
||||||
|
0x6, 0x3F, 0x3F, 0x11, 0x24, 0x7, 0x17,
|
||||||
|
};
|
||||||
|
|
||||||
|
UBYTE LUT_VCOM_7IN5_V2[]={
|
||||||
|
0x0, 0xF, 0xF, 0x0, 0x0, 0x1,
|
||||||
|
0x0, 0xF, 0x1, 0xF, 0x1, 0x2,
|
||||||
|
0x0, 0xF, 0xF, 0x0, 0x0, 0x1,
|
||||||
|
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||||
|
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||||
|
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||||
|
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||||
|
};
|
||||||
|
|
||||||
|
UBYTE LUT_WW_7IN5_V2[]={
|
||||||
|
0x10, 0xF, 0xF, 0x0, 0x0, 0x1,
|
||||||
|
0x84, 0xF, 0x1, 0xF, 0x1, 0x2,
|
||||||
|
0x20, 0xF, 0xF, 0x0, 0x0, 0x1,
|
||||||
|
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||||
|
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||||
|
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||||
|
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||||
|
};
|
||||||
|
|
||||||
|
UBYTE LUT_BW_7IN5_V2[]={
|
||||||
|
0x10, 0xF, 0xF, 0x0, 0x0, 0x1,
|
||||||
|
0x84, 0xF, 0x1, 0xF, 0x1, 0x2,
|
||||||
|
0x20, 0xF, 0xF, 0x0, 0x0, 0x1,
|
||||||
|
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||||
|
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||||
|
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||||
|
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||||
|
};
|
||||||
|
|
||||||
|
UBYTE LUT_WB_7IN5_V2[]={
|
||||||
|
0x80, 0xF, 0xF, 0x0, 0x0, 0x1,
|
||||||
|
0x84, 0xF, 0x1, 0xF, 0x1, 0x2,
|
||||||
|
0x40, 0xF, 0xF, 0x0, 0x0, 0x1,
|
||||||
|
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||||
|
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||||
|
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||||
|
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||||
|
};
|
||||||
|
|
||||||
|
UBYTE LUT_BB_7IN5_V2[]={
|
||||||
|
0x80, 0xF, 0xF, 0x0, 0x0, 0x1,
|
||||||
|
0x84, 0xF, 0x1, 0xF, 0x1, 0x2,
|
||||||
|
0x40, 0xF, 0xF, 0x0, 0x0, 0x1,
|
||||||
|
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||||
|
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||||
|
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||||
|
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||||
|
};
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Software reset
|
||||||
|
parameter:
|
||||||
|
******************************************************************************/
|
||||||
|
static void EPD_Reset(void)
|
||||||
|
{
|
||||||
|
DEV_Digital_Write(EPD_RST_PIN, 1);
|
||||||
|
DEV_Delay_ms(20);
|
||||||
|
DEV_Digital_Write(EPD_RST_PIN, 0);
|
||||||
|
DEV_Delay_ms(2);
|
||||||
|
DEV_Digital_Write(EPD_RST_PIN, 1);
|
||||||
|
DEV_Delay_ms(20);
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : send command
|
||||||
|
parameter:
|
||||||
|
Reg : Command register
|
||||||
|
******************************************************************************/
|
||||||
|
static void EPD_SendCommand(UBYTE Reg)
|
||||||
|
{
|
||||||
|
DEV_Digital_Write(EPD_DC_PIN, 0);
|
||||||
|
DEV_Digital_Write(EPD_CS_PIN, 0);
|
||||||
|
DEV_SPI_WriteByte(Reg);
|
||||||
|
DEV_Digital_Write(EPD_CS_PIN, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : send data
|
||||||
|
parameter:
|
||||||
|
Data : Write data
|
||||||
|
******************************************************************************/
|
||||||
|
static void EPD_SendData(UBYTE Data)
|
||||||
|
{
|
||||||
|
DEV_Digital_Write(EPD_DC_PIN, 1);
|
||||||
|
DEV_Digital_Write(EPD_CS_PIN, 0);
|
||||||
|
DEV_SPI_WriteByte(Data);
|
||||||
|
DEV_Digital_Write(EPD_CS_PIN, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Wait until the busy_pin goes LOW
|
||||||
|
parameter:
|
||||||
|
******************************************************************************/
|
||||||
|
static void EPD_WaitUntilIdle(void)
|
||||||
|
{
|
||||||
|
Debug("e-Paper busy\r\n");
|
||||||
|
do{
|
||||||
|
DEV_Delay_ms(5);
|
||||||
|
}while(!(DEV_Digital_Read(EPD_BUSY_PIN)));
|
||||||
|
DEV_Delay_ms(5);
|
||||||
|
Debug("e-Paper busy release\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void EPD_7IN5_V2_LUT(UBYTE* lut_vcom, UBYTE* lut_ww, UBYTE* lut_bw, UBYTE* lut_wb, UBYTE* lut_bb)
|
||||||
|
{
|
||||||
|
UBYTE count;
|
||||||
|
|
||||||
|
EPD_SendCommand(0x20); //VCOM
|
||||||
|
for(count=0; count<42; count++)
|
||||||
|
EPD_SendData(lut_vcom[count]);
|
||||||
|
|
||||||
|
EPD_SendCommand(0x21); //LUTBW
|
||||||
|
for(count=0; count<42; count++)
|
||||||
|
EPD_SendData(lut_ww[count]);
|
||||||
|
|
||||||
|
EPD_SendCommand(0x22); //LUTBW
|
||||||
|
for(count=0; count<42; count++)
|
||||||
|
EPD_SendData(lut_bw[count]);
|
||||||
|
|
||||||
|
EPD_SendCommand(0x23); //LUTWB
|
||||||
|
for(count=0; count<42; count++)
|
||||||
|
EPD_SendData(lut_wb[count]);
|
||||||
|
|
||||||
|
EPD_SendCommand(0x24); //LUTBB
|
||||||
|
for(count=0; count<42; count++)
|
||||||
|
EPD_SendData(lut_bb[count]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Turn On Display
|
||||||
|
parameter:
|
||||||
|
******************************************************************************/
|
||||||
|
static void EPD_7IN5_V2_TurnOnDisplay(void)
|
||||||
|
{
|
||||||
|
EPD_SendCommand(0x12); //DISPLAY REFRESH
|
||||||
|
DEV_Delay_ms(100); //!!!The delay here is necessary, 200uS at least!!!
|
||||||
|
EPD_WaitUntilIdle();
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Initialize the e-Paper register
|
||||||
|
parameter:
|
||||||
|
******************************************************************************/
|
||||||
|
UBYTE EPD_7IN5_V2_Init(void)
|
||||||
|
{
|
||||||
|
EPD_Reset();
|
||||||
|
|
||||||
|
// EPD_SendCommand(0x01); //POWER SETTING
|
||||||
|
// EPD_SendData(0x07);
|
||||||
|
// EPD_SendData(0x07); //VGH=20V,VGL=-20V
|
||||||
|
// EPD_SendData(0x3f); //VDH=15V
|
||||||
|
// EPD_SendData(0x3f); //VDL=-15V
|
||||||
|
|
||||||
|
EPD_SendCommand(0x01); // power setting
|
||||||
|
EPD_SendData(0x17); // 1-0=11: internal power
|
||||||
|
EPD_SendData(*(Voltage_Frame_7IN5_V2+6)); // VGH&VGL
|
||||||
|
EPD_SendData(*(Voltage_Frame_7IN5_V2+1)); // VSH
|
||||||
|
EPD_SendData(*(Voltage_Frame_7IN5_V2+2)); // VSL
|
||||||
|
EPD_SendData(*(Voltage_Frame_7IN5_V2+3)); // VSHR
|
||||||
|
|
||||||
|
EPD_SendCommand(0x82); // VCOM DC Setting
|
||||||
|
EPD_SendData(*(Voltage_Frame_7IN5_V2+4)); // VCOM
|
||||||
|
|
||||||
|
EPD_SendCommand(0x06); // Booster Setting
|
||||||
|
EPD_SendData(0x27);
|
||||||
|
EPD_SendData(0x27);
|
||||||
|
EPD_SendData(0x2F);
|
||||||
|
EPD_SendData(0x17);
|
||||||
|
|
||||||
|
EPD_SendCommand(0x30); // OSC Setting
|
||||||
|
EPD_SendData(*(Voltage_Frame_7IN5_V2+0)); // 2-0=100: N=4 ; 5-3=111: M=7 ; 3C=50Hz 3A=100HZ
|
||||||
|
|
||||||
|
EPD_SendCommand(0x04); //POWER ON
|
||||||
|
DEV_Delay_ms(100);
|
||||||
|
EPD_WaitUntilIdle();
|
||||||
|
|
||||||
|
EPD_SendCommand(0X00); //PANNEL SETTING
|
||||||
|
EPD_SendData(0x3F); //KW-3f KWR-2F BWROTP 0f BWOTP 1f
|
||||||
|
|
||||||
|
EPD_SendCommand(0x61); //tres
|
||||||
|
EPD_SendData(0x03); //source 800
|
||||||
|
EPD_SendData(0x20);
|
||||||
|
EPD_SendData(0x01); //gate 480
|
||||||
|
EPD_SendData(0xE0);
|
||||||
|
|
||||||
|
EPD_SendCommand(0X15);
|
||||||
|
EPD_SendData(0x00);
|
||||||
|
|
||||||
|
EPD_SendCommand(0X50); //VCOM AND DATA INTERVAL SETTING
|
||||||
|
EPD_SendData(0x10);
|
||||||
|
EPD_SendData(0x00);
|
||||||
|
|
||||||
|
EPD_SendCommand(0X60); //TCON SETTING
|
||||||
|
EPD_SendData(0x22);
|
||||||
|
|
||||||
|
EPD_SendCommand(0x65); // Resolution setting
|
||||||
|
EPD_SendData(0x00);
|
||||||
|
EPD_SendData(0x00);//800*480
|
||||||
|
EPD_SendData(0x00);
|
||||||
|
EPD_SendData(0x00);
|
||||||
|
|
||||||
|
EPD_7IN5_V2_LUT(LUT_VCOM_7IN5_V2, LUT_WW_7IN5_V2, LUT_BW_7IN5_V2, LUT_WB_7IN5_V2, LUT_BB_7IN5_V2);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Clear screen
|
||||||
|
parameter:
|
||||||
|
******************************************************************************/
|
||||||
|
void EPD_7IN5_V2_Clear(void)
|
||||||
|
{
|
||||||
|
UWORD Width, Height;
|
||||||
|
Width =(EPD_7IN5_V2_WIDTH % 8 == 0)?(EPD_7IN5_V2_WIDTH / 8 ):(EPD_7IN5_V2_WIDTH / 8 + 1);
|
||||||
|
Height = EPD_7IN5_V2_HEIGHT;
|
||||||
|
|
||||||
|
UWORD i;
|
||||||
|
EPD_SendCommand(0x10);
|
||||||
|
for(i=0; i<Height*Width; i++) {
|
||||||
|
EPD_SendData(0xFF);
|
||||||
|
}
|
||||||
|
EPD_SendCommand(0x13);
|
||||||
|
for(i=0; i<Height*Width; i++) {
|
||||||
|
EPD_SendData(0x00);
|
||||||
|
}
|
||||||
|
EPD_7IN5_V2_TurnOnDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
void EPD_7IN5_V2_ClearBlack(void)
|
||||||
|
{
|
||||||
|
UWORD Width, Height;
|
||||||
|
Width =(EPD_7IN5_V2_WIDTH % 8 == 0)?(EPD_7IN5_V2_WIDTH / 8 ):(EPD_7IN5_V2_WIDTH / 8 + 1);
|
||||||
|
Height = EPD_7IN5_V2_HEIGHT;
|
||||||
|
|
||||||
|
UWORD i;
|
||||||
|
EPD_SendCommand(0x10);
|
||||||
|
for(i=0; i<Height*Width; i++) {
|
||||||
|
EPD_SendData(0x00);
|
||||||
|
}
|
||||||
|
EPD_SendCommand(0x13);
|
||||||
|
for(i=0; i<Height*Width; i++) {
|
||||||
|
EPD_SendData(0xFF);
|
||||||
|
}
|
||||||
|
EPD_7IN5_V2_TurnOnDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Sends the image buffer in RAM to e-Paper and displays
|
||||||
|
parameter:
|
||||||
|
******************************************************************************/
|
||||||
|
void EPD_7IN5_V2_Display(const UBYTE *blackimage)
|
||||||
|
{
|
||||||
|
UDOUBLE Width, Height;
|
||||||
|
Width =(EPD_7IN5_V2_WIDTH % 8 == 0)?(EPD_7IN5_V2_WIDTH / 8 ):(EPD_7IN5_V2_WIDTH / 8 + 1);
|
||||||
|
Height = EPD_7IN5_V2_HEIGHT;
|
||||||
|
|
||||||
|
// EPD_SendCommand(0x10);
|
||||||
|
// for (UDOUBLE j = 0; j < Height; j++) {
|
||||||
|
// for (UDOUBLE i = 0; i < Width; i++) {
|
||||||
|
// EPD_SendData(blackimage[i + j * Width]);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
EPD_SendCommand(0x13);
|
||||||
|
for (UDOUBLE j = 0; j < Height; j++) {
|
||||||
|
for (UDOUBLE i = 0; i < Width; i++) {
|
||||||
|
EPD_SendData(~blackimage[i + j * Width]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EPD_7IN5_V2_TurnOnDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Enter sleep mode
|
||||||
|
parameter:
|
||||||
|
******************************************************************************/
|
||||||
|
void EPD_7IN5_V2_Sleep(void)
|
||||||
|
{
|
||||||
|
EPD_SendCommand(0X02); //power off
|
||||||
|
EPD_WaitUntilIdle();
|
||||||
|
EPD_SendCommand(0X07); //deep sleep
|
||||||
|
EPD_SendData(0xA5);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user