Skip to content

Commit

Permalink
Display Flush fix plus extra SPI displays (nanoframework#1788)
Browse files Browse the repository at this point in the history
* Display Flush fix plus extra SPI displays

* Code style fixes

Automated fixes for code style.

* Auto stash before merge of "ui-fixes" and "upstream/nfbot/clang-format-fix/875c8a43-7dbb-4855-adf7-46061a013be0"

* Revert "Auto stash before merge of "ui-fixes" and "upstream/nfbot/clang-format-fix/875c8a43-7dbb-4855-adf7-46061a013be0""

This reverts commit 361d59e.

* Remove comment

Co-authored-by: nfbot <nanoframework@outlook.com>
  • Loading branch information
AdrianSoundy and nfbot authored Nov 23, 2020
1 parent 42198a2 commit 3a2d2c5
Show file tree
Hide file tree
Showing 11 changed files with 1,612 additions and 547 deletions.
26 changes: 13 additions & 13 deletions src/nanoFramework.Graphics/Graphics/Displays/Display.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,29 @@

#include "nanoCLR_Types.h"

#define LCD_COLOUR_RGB(R,G,B) ((CLR_UINT16)((((R) / 8) << 11) + (((G) / 4) << 5) + ((B) / 8)))

enum DisplayOrientation : CLR_INT16
{
PORTRAIT,
PORTRAIT180,
LANDSCAPE,
LANDSCAPE180
};
enum PixelFormat : CLR_UINT8 {
FORMAT_RGB888 = 0, // Pixel format chosen is RGB888 : 24 bpp
FORMAT_RBG565 = 2, // Pixel format chosen is RGB565 : 16 bpp
enum PixelFormat : CLR_UINT8
{
FORMAT_RGB888 = 0, // Pixel format chosen is RGB888 : 24 bpp
FORMAT_RBG565 = 2, // Pixel format chosen is RGB565 : 16 bpp
};
enum PowerSaveState : CLR_UINT8 {
enum PowerSaveState : CLR_UINT8
{
NORMAL = 0,
SLEEP = 1
};
struct DisplayAttributes
{
CLR_UINT8* TransferBuffer = NULL;
CLR_UINT8 *TransferBuffer = NULL;
CLR_UINT32 TransferBufferSize;
PowerSaveState PowerSave;
DisplayOrientation Orientation; //Future
DisplayOrientation Orientation; // Future
CLR_INT16 Height;
CLR_INT16 Width;
CLR_INT16 BitsPerPixel;
Expand All @@ -39,23 +39,23 @@ struct DisplayAttributes
};
struct DisplayDriver
{
//CLR_UINT32* g_FrameBuffer; // = NULL -- copied from netmg ( not sure it is needed based on new implementation)
//CLR_UINT32 g_FrameBufferSize; // = 0; -- copied from netmg ( not sure it is needed)
//bool g_LcdInitialized; // = false; ---copied from netmg ( not sure it is needed)

DisplayAttributes Attributes;

void SetupDisplayAttributes();
bool Initialize();
bool Uninitialize();
void Clear();
void DisplayBrightness(CLR_INT16 brightness);
bool SetWindow(CLR_INT16 x1, CLR_INT16 y1, CLR_INT16 x2, CLR_INT16 y2);
void BitBlt(int x, int y, int width, int height, CLR_UINT32 data[]);
void PowerSave(PowerSaveState powerState);
void SetDefaultOrientation();
bool ChangeOrientation(DisplayOrientation orientation);

CLR_UINT32 PixelsPerWord();
CLR_UINT32 WidthInWords();
CLR_UINT32 SizeInWords();
CLR_UINT32 SizeInBytes();
};
#endif

#endif
35 changes: 17 additions & 18 deletions src/nanoFramework.Graphics/Graphics/Displays/DisplayInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,34 @@

#include "nanoCLR_Types.h"

// DIsplay configuration
union DisplayInterfaceConfig
{
struct
// Display configuration
union DisplayInterfaceConfig {
struct
{
CLR_INT8 spiBus;
GPIO_PIN chipSelect;
GPIO_PIN dataCommand;
GPIO_PIN reset;
GPIO_PIN backLight;
CLR_INT8 spiBus;
GPIO_PIN chipSelect;
GPIO_PIN dataCommand;
GPIO_PIN reset;
GPIO_PIN backLight;
} Spi;
struct
struct
{
CLR_INT8 i2cBus;
CLR_INT8 address;
CLR_INT8 i2cBus;
CLR_INT8 address;
CLR_INT8 fastMode;
} I2c;
};


struct DisplayInterface
{
void Initialize(DisplayInterfaceConfig& config);
void GetTransferBuffer(CLR_UINT8*& BufferAddress, CLR_UINT32& sizeInBytes);
void Initialize(DisplayInterfaceConfig &config);
void GetTransferBuffer(CLR_UINT8 *&BufferAddress, CLR_UINT32 &sizeInBytes);
void ClearFrameBuffer();
void WriteToFrameBuffer(CLR_UINT8 command, CLR_UINT8 data[], CLR_UINT32 dataCount);
void WriteToFrameBuffer(CLR_UINT8 command, CLR_UINT8 data[], CLR_UINT32 dataCount, CLR_UINT32 frameOffset = 0);
void DisplayBacklight(bool on); // true = on
void SendCommand(CLR_UINT8 arg_count, ...);
void SendBytes(CLR_UINT8 *data, CLR_UINT32 length);
void SetCommandMode(int mode);
};


#endif // _DISPLAY_INTERFACE_H_
#endif // _DISPLAY_INTERFACE_H_
Loading

0 comments on commit 3a2d2c5

Please sign in to comment.