Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdint.h>
- #include <string.h>
- #include <windows.h>
- typedef struct
- {
- #define NUM_OF_SENS 5
- char out[ NUM_OF_SENS * 7 ];
- uint16_t temp[NUM_OF_SENS];
- }sd_t;
- uint8_t tempToStr( sd_t *sd )
- {
- char result[4] = "";
- memset( ( char* )sd->out , 0 , NUM_OF_SENS * 7 ); // Speicher löschen
- uint8_t x;
- for( x = 0 ; x < NUM_OF_SENS ; x++ )
- {
- if( sd->temp[x] > 300 || sd->temp[x] == 0 ) // Fehler ist aufgetreten
- {
- return 1;
- }
- strcat( sd->out , itoa( x + 1 , result , 10 ) );
- strcat( sd->out , "#" );
- itoa( sd->temp[x] , result, 10 );
- strcat( sd->out + strlen( sd->out ) , result );
- strcat( sd->out , " " );
- }
- strcat( sd->out , "\r\n" );
- return 0;
- }
- int main ()
- {
- sd_t tmp;
- uint8_t i;
- for( i = 0 ; i < 32 ; i++ ) // Anzahl der Messungen ( 32 )
- {
- tmp.temp[0] = 4; // Hier Temperatur 1
- tmp.temp[1] = 254; // Hier Temperatur 2
- tmp.temp[2] = 33;
- tmp.temp[3] = 21;
- tmp.temp[4] = 11;
- tempToStr( &tmp );
- printf( tmp.out ); // Hier muss später deine Funktion zum schreiben auf die SD Karte hin!
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement