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