Display.h
author StephaneLenclud
Wed, 06 May 2015 21:25:49 +0200
changeset 37 d3b88ef66bfe
parent 32 2c844ef1ff4b
permissions -rw-r--r--
Trying to sort out our interop nicely.
     1 //
     2 // Copyright (C) 2014-2015 Stéphane Lenclud.
     3 //
     4 // This file is part of MiniDisplay.
     5 //
     6 // MiniDisplay is free software: you can redistribute it and/or modify
     7 // it under the terms of the GNU General Public License as published by
     8 // the Free Software Foundation, either version 3 of the License, or
     9 // (at your option) any later version.
    10 //
    11 // MiniDisplay is distributed in the hope that it will be useful,
    12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
    13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    14 // GNU General Public License for more details.
    15 //
    16 // You should have received a copy of the GNU General Public License
    17 // along with MiniDisplay.  If not, see <http://www.gnu.org/licenses/>.
    18 //
    19 
    20 #ifndef DISPLAY_H
    21 #define DISPLAY_H
    22 
    23 #include "MiniDisplay.h"
    24 #include "HidDevice.h"
    25 const int KMaxDisplayStringLength = 256;
    26 
    27 /**
    28 Define an interface to some basic display functionality
    29 */
    30 class DisplayBase: public HidDevice
    31 	{
    32 public:
    33 	DisplayBase():iRequest(EMiniDisplayRequestNone),iPowerOn(false)
    34 		{	    
    35 		iDeviceId[0]=0;
    36 		iFirmwareRevision[0]=0;
    37 		}
    38 
    39 	virtual ~DisplayBase(){};
    40 	//
    41 	virtual int Open()=0;
    42 	virtual void Close()=0;
    43 	//
    44 	virtual int MinBrightness() const=0;
    45 	virtual int MaxBrightness() const=0;
    46 	virtual void SetBrightness(int aBrightness)=0;
    47 	//
    48 	virtual void Clear()=0;
    49 	virtual void Fill()=0;
    50 	//
    51 	virtual void SwapBuffers()=0;
    52 
    53 	//Request management
    54 	virtual void Request(TMiniDisplayRequest /*aRequest*/){ /*No request supported by default*/ };
    55 	virtual TMiniDisplayRequest AttemptRequestCompletion(){return EMiniDisplayRequestNone;};
    56 	
    57 	virtual TMiniDisplayRequest CurrentRequest(){return iRequest;}
    58     virtual void CancelRequest(){iRequest=EMiniDisplayRequestNone;}
    59 	virtual bool RequestPending(){return iRequest!=EMiniDisplayRequestNone;}
    60 
    61     virtual bool IsPowerOn()	{return iPowerOn;}
    62 	virtual char* DeviceId() {return iDeviceId;}
    63 	virtual char* FirmwareRevision() {return iFirmwareRevision;}
    64 
    65 	virtual void TurnPowerOn(){}
    66 	virtual void TurnPowerOff(){}
    67 	virtual bool SupportPowerOnOff(){return false;}
    68 
    69 	virtual void ShowClock(){}
    70 	virtual void HideClock(){}
    71 	virtual bool SupportClock(){return false;}
    72 
    73 	//Icon management
    74 	//Icon support queries return the number of segments an icon supports.
    75 	virtual int IconCount(TMiniDisplayIconType /*aIcon*/){return 0;}
    76 	virtual int IconStatusCount(TMiniDisplayIconType /*aIcon*/){return 0;}
    77 	virtual void SetIconStatus(TMiniDisplayIconType /*aIcon*/, int /*aIndex*/, int /*aStatus*/){}
    78 
    79 protected:
    80 	void SetRequest(TMiniDisplayRequest aRequest) { iRequest=aRequest; }
    81 
    82 protected:
    83 	char iDeviceId[KMaxDisplayStringLength];
    84 	char iFirmwareRevision[KMaxDisplayStringLength];
    85     bool iPowerOn;
    86 
    87 
    88 private:
    89 	TMiniDisplayRequest iRequest;
    90 	};
    91 
    92 
    93 /**
    94 */
    95 class GraphicDisplay : public DisplayBase
    96 	{
    97 public:
    98 	virtual int WidthInPixels() const=0;
    99 	virtual int HeightInPixels() const=0;
   100 	virtual void SetPixel(unsigned char aX, unsigned char aY, unsigned int aPixel)=0;
   101 	virtual void SetAllPixels(unsigned char aOn)=0;
   102 	virtual int FrameBufferSizeInBytes() const=0;
   103 	//virtual int BitBlit(unsigned char* aSrc, unsigned char aSrcWidth, unsigned char aSrcHeight, unsigned char aTargetX, unsigned char aTargetY) const=0;
   104 
   105 	};
   106 
   107 
   108 
   109 #endif