Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display Flush fix plus extra SPI displays #1788

Merged
merged 9 commits into from
Nov 23, 2020
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