|
PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
|
23 void colorPal_reset(colorPal *device)
25 colorPal_t *cp = (colorPal_t*) device->devst;
28 while(
input(cp->rx_pin) == 0);
36 void colorPal_init(colorPal *device)
38 colorPal_t *cp = (colorPal_t*) device->devst;
40 colorPal_reset(device);
41 dprint(device,
"=(00 $ m)!");
49 char rs[4], gs[4], bs[4];
56 for(
int i = 0; i < 3; i++)
61 for(
int i = 0; i < 3; i++)
66 for(
int i = 0; i < 3; i++)
86 extern int binary_pst_dat_start[];
88 colorPal_t *colpalptr;
95 colorPal* term = (colorPal*) malloc(
sizeof(colorPal));
96 memset(term, 0,
sizeof(colorPal));
98 colpalptr = (
void*) malloc(
sizeof(colorPal_t));
99 term->
devst = colpalptr;
100 memset((
char*)colpalptr, 0,
sizeof(colorPal_t));
102 if(rxpin == 31 && txpin == 30) {
110 colpalptr->rx_pin = rxpin;
111 colpalptr->tx_pin = txpin;
112 colpalptr->mode = mode;
116 colpalptr->ticks =
CLKFREQ/baudrate;
117 colpalptr->buffptr = bufptr;
130 term->
cogid[0] = setStopCOGID(
cognew((
void*)binary_pst_dat_start, (
void*)colpalptr));
143 int id = device->cogid[0];
144 colorPal_t *colpalptr = (colorPal_t*) device->devst;
150 if(
id > 0)
cogstop(getStopCOGID(
id));
152 free((
void*)colpalptr->buffptr);
154 free((
void*)colpalptr);
170 r = 21 * r / 11 - 65 - ( r * r / 415 );
171 g = 48 * g / 17 - 70 - ( g * g / 170 );
172 b = 8 * b / 9 - 30 - ( b * b / 1680 );
174 if( r < 0 ) r = 0;
if( r > 255 ) r = 255;
175 if( g < 0 ) g = 0;
if( g > 255 ) g = 255;
176 if( b < 0 ) b = 0;
if( b > 255 ) b = 255;
178 return ((r & 0xFF) << 16 | (g & 0xFF) << 8 | (b & 0xFF));
#define FDSERIAL_BUFF_MASK
unsigned int colorPalRRGGBB(int r, int g, int b)
Supplies 8-bit white balanced approximations of ColorPal sensor's 12-bit values. Note: The rgb parame...
int(* rxChar)(struct text_struct *p)
void colorPal_getRGB(colorPal *device, int *r, int *g, int *b)
Get RGB (red green blue) values from the ColorPAL sensor.
int(* txChar)(struct text_struct *p, int ch)
#define cognew(code, param)
Start a new Propeller PASM COG.
Simplifies reading Parallax ColorPAL sensor.
int fdserial_rxCheck(fdserial *term)
Gets a byte from the receive buffer if available, but does not wait if there's nothing in the buffer.
int dprint(text_t *device, const char *format,...) __attribute__((format(printf
Print format "..." args to the device The output is limited to 256 bytes.
void simpleterm_close(void)
Closes the SimpleIDE Terminal connection in one cog so that it can be opened in another cog with simp...
int readChar(text_t *device)
Get char from the device.
#define CLKFREQ
Returns the current clock frequency.
void fdserial_rxFlush(fdserial *term)
Empties the receive buffer.
void fdserial_txFlush(fdserial *term)
Remove any bytes that might be waiting in the transmit buffer.
void colorPal_close(colorPal *device)
Close a connection and recover all memory set aside for the ColorPal sensor instance.
int fdserial_txChar(fdserial *term, int txbyte)
Send a byte by adding it to the transmit buffer.
#define waitcnt(a)
Wait until system counter reaches a value.
#define cogstop(a)
Stop a COG.
#define CNT
The system clock count.
colorPal * colorPal_open(int sioPin)
Open a connection to a Parallax ColorPAL sensor.
int fdserial_rxChar(fdserial *term)
Get a byte from the receive buffer, or if it's emtpy, wait until a byte is received.
This library supports creating and managing one or more full duplex serial connections with periphera...
int int int int sscan(const char *buffer, const char *fmt,...) __attribute__((format(printf
Convert formatted buffer to the "..." args.