Fall es jmd etwas ähnliches vorhat, stelle ich eine host-lauffähige Version des Ganzen mal hier rein.
Anhang in *.zip umbenennen und *.c und *.h finden.
Vorschau:
Code: Alles auswählen
/*
* readable version of the TV-B-Gone code compression
* hardware independent, runs on host systems
* by Nero 2015
* origins from
* TV-B-Gone Firmware version 1.2
* for use with ATtiny85v and v1.2 hardware
* (c) Mitch Altman + Limor Fried 2009
* Last edits, August 16 2009
* and
* With some code from:
* Kevin Timmerman & Damien Good 7-Dec-07
*
* Distributed under Creative Commons 2.5 -- Attib & Share Alike
*
* for eu codes
*/
#include <stdio.h>
#include "codes.h"
unsigned char uncompress_code(const unsigned char * c_field, unsigned char offs, unsigned char bit_compression)
{
int i;
unsigned char tmp = 0;
unsigned char byte_num = offs * bit_compression / 8;
unsigned char bit_num = 7 - ((offs * bit_compression) % 8);
for (i = 0; i < bit_compression; i++) {
if (bit_num < 0) {
byte_num++;
bit_num = 7;
}
tmp |= ( ((c_field[byte_num] >> bit_num) & 1) << (bit_compression - 1 - i) );
bit_num--;
}
// return the selected bits in the LSB part of tmp
return tmp;
}
void transmit_code(unsigned short on, unsigned short off, unsigned int f)
{
return;
}
int main(void)
{
unsigned short ontime, offtime;
unsigned char i,k;
unsigned int freq;
unsigned char numpairs;
unsigned char bitcompression;
unsigned char ti;
int sumofcodepais = 0;
// for every POWER code in our collection
for(i=0 ; i < num_EUcodes; i++) {
// Read the carrier frequency from the code structure
freq = EUpowerCodes[i]->timer_val;
numpairs = EUpowerCodes[i]->numpairs;
bitcompression = EUpowerCodes[i]->bitcompression;
// Transmit all codeElements for this POWER code
// (a codeElement is an onTime and an offTime)
// transmitting onTime means pulsing the IR emitters at the carrier
// frequency for the length of time specified in onTime
// transmitting offTime means no output from the IR emitters for the
// length of time specified in offTime
sumofcodepais += numpairs;
printf(" k ti on_t off_t\n");
// For EACH pair in this code....
for (k=0; k < numpairs; k++) {
ti = uncompress_code(EUpowerCodes[i]->codes, k, bitcompression);
// read the onTime and offTime from the program memory
ontime = EUpowerCodes[i]->times[2*ti]; // read word 1 - ontime
offtime = EUpowerCodes[i]->times[2*ti + 1]; // read word 2 - offtime
// transmit this codeElement (ontime and offtime)
transmit_code(ontime, offtime, freq);
printf("%5d %5d %5d %5d\n", k, ti, ontime, offtime);
}
}
printf("\ntotal number of code pairs: %d\n", sumofcodepais);
return 0;
}