PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Simple Libraries
Social
libbadgetools
leds_set_1_blue.c
1
#include <propeller.h>
2
#include "
badgetools.h
"
3
4
light
badgeLight;
5
light
*ledsself;
6
7
int32_t cpcog;
8
9
void
set_1_blue(int32_t idx)
10
{
11
//int32_t result = 0;
12
// LOCKED 30 JUN 2015
13
// Set one of the six blue LEDs
14
// -- connections designed for Charlieplexing
15
// * make one high, one low, the other high-z (input)
16
// -- for multiple LEDs use Charlieplex driver methods
17
18
if
(cpcog) {
19
// Charlieplex driver loaded?
20
if
((idx >= BLUE_0) && (idx <= BLUE_5)) {
21
// valid element?
22
// set via mask
23
led_on((1 << idx));
24
}
else
{
25
// clear all
26
leds
(0b000000);
27
}
28
return
;
29
}
30
// if no driver loaded, use direct control
31
if
(idx == BLUE_0) {
32
// CP2 = L, CP1 = H, CP0 = Z
33
OUTA
= ((
OUTA
& 0xfffffe3f) | 0x80);
34
DIRA
= ((
DIRA
& 0xfffffe3f) | 0x180);
35
}
else
if
(idx == BLUE_1) {
36
// CP2 = H, CP1 = Z, CP0 = L
37
OUTA
= ((
OUTA
& 0xfffffe3f) | 0x100);
38
DIRA
= ((
DIRA
& 0xfffffe3f) | 0x140);
39
}
else
if
(idx == BLUE_2) {
40
// CP2 = L, CP1 = Z, CP0 = H
41
OUTA
= ((
OUTA
& 0xfffffe3f) | 0x40);
42
DIRA
= ((
DIRA
& 0xfffffe3f) | 0x140);
43
}
else
if
(idx == BLUE_3) {
44
// CP2 = H, CP1 = L, CP0 = Z
45
OUTA
= ((
OUTA
& 0xfffffe3f) | 0x100);
46
DIRA
= ((
DIRA
& 0xfffffe3f) | 0x180);
47
}
else
if
(idx == BLUE_4) {
48
// CP2 = Z, CP1 = H, CP0 = L
49
OUTA
= ((
OUTA
& 0xfffffe3f) | 0x80);
50
DIRA
= ((
DIRA
& 0xfffffe3f) | 0xc0);
51
}
else
if
(idx == BLUE_5) {
52
// CP2 = Z, CP1 = L, CP0 = H
53
OUTA
= ((
OUTA
& 0xfffffe3f) | 0x40);
54
DIRA
= ((
DIRA
& 0xfffffe3f) | 0xc0);
55
}
else
if
(1) {
56
// disable all
57
OUTA
&= ~(7<<
BLU_CP0
);
58
DIRA
&= ~(7<<
BLU_CP0
);
59
}
60
}
61
62
/*
63
TERMS OF USE: MIT License
64
65
Permission is hereby granted, free of charge, to any person obtaining a
66
copy of this software and associated documentation files (the "Software"),
67
to deal in the Software without restriction, including without limitation
68
the rights to use, copy, modify, merge, publish, distribute, sublicense,
69
and/or sell copies of the Software, and to permit persons to whom the
70
Software is furnished to do so, subject to the following conditions:
71
72
The above copyright notice and this permission notice shall be included in
73
all copies or substantial portions of the Software.
74
75
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
76
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
77
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
78
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
79
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
80
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
81
DEALINGS IN THE SOFTWARE.
82
*/
83
OUTA
#define OUTA
Use to set output pin states when corresponding DIRA bits are 1.
Definition:
propeller1.h:157
light
Definition:
badgetools.h:1224
BLU_CP0
#define BLU_CP0
brief description.
Definition:
badgetools.h:1200
leds
void leds(int bits)
Sets the on/off states of the 6 blue LEDs with a number that contains six binary 1/0 digits....
badgetools.h
This library provides convenient functions for a variety of Parallax eBadge operations.
DIRA
#define DIRA
Use to set pins to input (0) or output (1).
Definition:
propeller1.h:161
Generated on Fri May 20 2022 16:48:05 for PropWare by
1.8.17