summaryrefslogtreecommitdiffstats
path: root/source/Concept/Framework/modules/output/led.h
blob: 08e7466f35d11c5462b2e393f77e6329f57018ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef _LED_H
#define _LED_H

#include "../../stdafx.h"

class Led : public IO_Module
{
public:
	Led()
	{
		this->enabled = false;
		this->parent = NULL;
		this->moduleId = 0;
		this->hardwarePort = NULL;
		this->pinPower = 0;
	}

	Led(uint32 ledId)
	{
		this->enabled = false;
		this->parent = NULL;
		this->moduleId = ledId;

		switch(ledId)
		{
			case IO_LED_MAIN:
				this->hardwarePort = &PORTB;
				this->pinPower = (1 << 1);
				break;
			default:
				this->hardwarePort = NULL;
				this->pinPower = 0;
				break;
		}
	}

protected:
	bool enabled;

	//Hardware
	volatile uint8* hardwarePort;
	uint8 pinPower;

public:
	bool GetEnabled()
	{
		return enabled;
	}

	void SetEnabled(bool newStatus)
	{
		enabled = newStatus;

		if(enabled)
		{
			*hardwarePort &= ~pinPower;
		}
		else
		{
			*hardwarePort |= pinPower;
		}
	}
};

#endif