示例#1
0
int16_t parse_cmd_stella_channel (char *cmd, char *output, uint16_t len)
{
	char f=0;
	uint8_t ch=0;
	uint8_t value=0;
	int8_t ret = 0;
	if (cmd[0]!=0) ret = sscanf_P(cmd, PSTR("%u %u %c"), &ch, &value, &f);
	
	if (f=='s') f = 0; // set
	else if (f=='f') f = 1; // fade
	else if (f=='y') f = 2; // fade variant 2

	// return all channel values
	if (ret == 0)
	{
		ret = 0;
		for (ch = 0; ch<STELLA_PINS*4; ch+=4,++ret)
		{
			value = stella_getValue(ret);
			output[ch+2] = value%10 +48;
			value /= 10;
			output[ch+1] = value%10 +48;
			value /= 10;
			output[ch+0] = value%10 +48;
			output[ch+3] = '\n';
		}
		if (ch>0) --ch;
		return ch;
	}
	// return one channel value
	else if (ret == 1)
	{
		if (ch>=STELLA_PINS) return ECMD_ERR_PARSE_ERROR;

		return ECMD_FINAL(snprintf_P(output, len, PSTR("%u"), stella_getValue(ch)));
	}
	// else set channel to value
	else if (ret >= 2)
	{
		if (ch>=STELLA_PINS) return ECMD_ERR_PARSE_ERROR;
		stella_setValue(f, ch, value);

		return ECMD_FINAL_OK;
	}
	else
		return ECMD_ERR_PARSE_ERROR;
}
示例#2
0
inline void sendStella(void)
{
    unsigned char data[4+STELLA_CHANNELS] = {'O','K','L',STELLA_CHANNELS};

    for (uint8_t i=0;i<STELLA_CHANNELS;++i)
        data[i+4] = stella_getValue(i);
	for (uint8_t i=0;i<sizeof(data);++i)
		uart_putc(data[i]);
}
示例#3
0
inline void storeValues(void) {
	for (uint8_t i=0;i<STELLA_CHANNELS;++i) {
		storedValues[i] = stella_getValue(i);
		stella_setValue(STELLA_SET_FADE, i, 0);
	}
}