Projekte
BirgerT
nibo2_MyWorx
main.c
Projekte
Forum
Doku
Öffentliche Projekte
Startseite
Beispielprogramme
Projekte von anderen
Welcome
Username
Passwort
Eingeloggt bleiben
Zugangsdaten vergessen?
Registrieren
Projektverwaltung
⇨ Please choose! ⇦
——————————————————
✎ Create new project...
★ Browse existing projects...
——————————————————
⚬ MotorTest#1
⚬ C Tutorial 8#1
⚬ NIBO2 C Project#1
⚙ C Tutorial 15#1
⚬ 2010_11_18_el_test001#1
nibo2_MyWorx
liesmich.txt
main.c
nibo2_akku.c
nibo2_akku.h
nibo2_audio.c
nibo2_audio.h
nibo2_audio_titels.c
nibo2_globaldef.h
nibo2_parameter.c
nibo2_parameter.h
nibo2_sensors.c
nibo2_sensors.h
nibo2_timer2.c
nibo2_timer2.h
nibo2_tour.c
nibo2_tour.h
nibo2_xbmgfx.c
nibo2_xbmgfx.h
Studio6_m...x_hex.txt
Project details
Compiler settings
Nachrichten
Sie sind nicht eingeloggt.
Neuigkeiten
★
NiboRoboLib 3.6
2017-01-17: Neue Version 3.6
★
NiboRoboLib 3.4.1
2016-04-16: Neue Version 3.4.1
★
Coding Tutorial
2015-11-22: Jetzt auch für den NIBO burger!
Site-Statistic
7427 private projects
385 public projects
16181052 lines compiled
58220 builds
NIBO
@
nibo2_MyWorx/main.c [read only]
/* NIBO 2 Test Soundausgabe BSD License see "liesmich.txt" */ // Einbinden NIBO2 Header und Makros #include "nibo2_globaldef.h" // Akku Ladeanzeige #include "nibo2_akku.h" // xbm Grafikbiblithek #include "nibo2_xbmgfx.h" // Fahrprogramme #include "nibo2_tour.h" // Parameter- und Hardwaretest #include "nibo2_parameter.h" // Nachfolgendes #if: // 1==1 damit der Build mit alter NiboLib2.11 möglich ist (Roboter.CC) // 1==0 für Build mit Lib aus Repository trunk167 o. neuer #if 1==1 // Diese Funktion wurde in der gfx Bibliothek vergessen, // obwohl sie in der gfx.h. deklariert ist... static uint8_t gfx_term_col=0, gfx_term_row=0; void gfx_term_print_P(PGM_P text) { gfx_set_proportional(0); uint8_t c; while ((c = pgm_read_byte(text++))) { if (c==10) { gfx_term_col = 0; gfx_term_row++; if (gfx_term_row==8) { gfx_term_scroll(1); } } else if (c==13) { } else { if (gfx_term_col>=21) { gfx_term_col = 0; gfx_term_row++; if (gfx_term_row==8) { gfx_term_scroll(1); } } gfx_move(gfx_term_col*6, gfx_term_row*8); gfx_print_char(c); gfx_term_col++; } } } #endif // endif // Distanzsensortastatur #include "nibo2_sensors.h" // Akku Ladeanzeige #include "nibo2_akku.h" // RTTTL Klingeltoene spielen #include "nibo2_audio.h" const char PROGMEM Toene[] = \ // C0, C0_, D0, D0_, E0, F0, F0_, G0, G0_, A0, A0_, H0, "Tonleiter:d=2,o=6,b=200:b,c,c#,d.d#,e,f,f#,g,g#,a,a#,b"; const char PROGMEM Programm[] =\ "- NIBO 2 SoundCheck -\n\n\ Distanzsensoren als\n\ Tasten benutzbar!\n\n\ Weiter mit SW3\ "; //*************************************** FAST TASK TEST // wird alle 1ms von Timer2 ISR aufgerufen void Test_FastTask(void){ static uint16_t takt = 0; #define HL_ON 30 #define HL_OFF 50 #define HL_TIME (HL_ON + HL_OFF) #define HL_ZYKL (3*3*HL_TIME) switch(takt++){ case 1*HL_TIME: case 2*HL_TIME: case 3*HL_TIME: HEADLIGHT(1024);break; case 1*HL_TIME+HL_ON: case 2*HL_TIME+HL_ON: case 3*HL_TIME+HL_ON: HEADLIGHT(0); break; case HL_ZYKL: takt = 0; break; } } // ************************************************** MAIN int main() { // die uebliche Nibo2 Initialisierung leds_init(); display_init(); gfx_init(); pwm_init(); bot_init(); spi_init(); floor_init(); delay(10); copro_ir_startMeasure(); // Headlights mit 1000 hell genug leds_set_displaylight(1000); // LED gedimmt == schoenere Farben leds_set_status_intensity(300); // Ist SW3 gedrueckt.. if(!get_input_bit(IO_INPUT_1)){ // ..zur Testseite parameter_start(); } // Programmbeschreibung aufs Display gfx_term_print_P(Programm); /* FastTask in Timer2 ISR anmelden */ timer2_init(&Test_FastTask); /* AUDIO ISR in Timer2 ISR anmelden */ audio_init(); sei(); uint8_t songnr = 0; // Wiedergabe starten.. audio_play_song_P(audio_start_titel_P(songnr)); // ..und warten bis fertig while((Audio_Status == PLAY) && !KEY_SW3){ audio_play_song_P(0); } gfx_fill(0); uint8_t scheduler = 80; int8_t ball_x = 20; int8_t ball_dx = 5; int8_t ball_y = 20; int8_t ball_dy = 3; draw_icon(ball_x,ball_y,xbm_ball8); uint8_t smi = xbm_smily1; uint8_t smx = (GFX_DISP_WIDTH-16)/2; // uint8_t smx = 103; uint8_t smy = (GFX_DISP_HEIGHT-16)/2; // uint8_t smy = 26; uint8_t waitplay = 0; uint8_t tourplay = 0; /*! * Regelungsparameter für @see copro_setTarget, @see copro_setTargetRel und @see copro_setSpeed setzen. * Die Standardwerte sind im Normalfall ausreichend * Die Werte werden im EEPROM gespeichert. Weitere Infos im Wiki unter * http://www.nibo-roboter.de/wiki/Motorcontroller-Firmware * @param kp Proportionalanteil, Standardwert: 5 * @param ki Integralanteil, Standardwert: 6 * @param kd Differentialanteil, Standardwert: 7 uint8_t copro_setSpeedParameters(int8_t kp, int8_t ki, int8_t kd); */ // 18.05.2014 Auf der Suche nach der besten Einstellung, festgestellt, dass Default besser ist // copro_setSpeedParameters(2, 6, 6); copro_setSpeedParameters(5, 6, 7); //******************************************** MAINLOOP while(1==1) { sei(); // Zeitbasis Umlaufverzoegerung #define ZEITBASIS 100 int16_t old_time = pwm_timer_ms; //*************** DISTANZSENSOREN ALS TASTEN sensors_update(); // Sensoren einlesen sensors_show(); // Sensoren Status LED bot_update(); // Bot Daten aktualisieren akku_draw(); // Akku Symbol Ladezustand akku_volt(); // Akku Spannungsanzeige // copro_update(); // Motorcontroller Werte //*************** FRONTSENSOR STARTET AKTION if(KEY_STOP_PRESS) { // Distanzsensor vorne if(++songnr > 15) songnr = 0; audio_play_song_P(audio_start_titel_P(songnr)); // definierte Tour abfahren tourplay = tour_play(tour1); } // Tour Play aufrufen, bis abgefahren if(tourplay != 0) tourplay = tour_play(0); // schraege Toene mit SW3 if(KEY_SW3_PRESS){ audio_play_tone(H5,50); audio_play_tone(P__,50); audio_play_tone(C6,50); audio_play_tone(P__,50); audio_play_tone(D6,50); audio_play_tone(P__,50); audio_play_song_P(Toene); } // gfx_buffertest(); //*************** SMILY ANIMATION TEST *****/ gfx_draw_mode(GFX_DM_JAM2); // ueberschreiben switch(scheduler--) { case 80: smi = xbm_smily1; break; case 60: smi = xbm_smily2; break; case 40: smi = xbm_smily3; break; case 20: smi = xbm_smily4; break; case 0: scheduler = 80; break; } //*************** SPRINGENDER BALL ANIMATION *****/ // Sound, wenn Ball am Rand #define PLOPP if(Audio_Status == READY) audio_play_tone(C3,6) if(ball_x >= (GFX_DISP_WIDTH-10-32)) {ball_dx = -5; PLOPP;} else if(ball_x < 3) {ball_dx = 4;PLOPP;} if(ball_y >= (GFX_DISP_HEIGHT-10)) {ball_dy = -3;PLOPP;} else if(ball_y < 2) {ball_dy = 3;PLOPP;} // Ball an alter Position löschen gfx_draw_mode(GFX_DM_COMP); // XOR schreiben draw_icon(ball_x,ball_y,xbm_ball8); draw_icon(smx,smy,smi); // Neue Ballposition ball_x += ball_dx; ball_y += ball_dy; if(ball_x > (GFX_DISP_WIDTH-10-32)) {ball_x = GFX_DISP_WIDTH-10-32;} if(ball_x < 1) {ball_x = 1;} if(ball_y > (GFX_DISP_HEIGHT-10)) {ball_y = GFX_DISP_HEIGHT-10;} if(ball_y < 1) {ball_dy = 1;} // Smily mit Sensortasten bewegen if(KEY_LEFT && (smx>0)) smx--; if(KEY_RIGHT && (smx < (GFX_DISP_WIDTH-16))) smx++; if(KEY_UP && (smy>0)) smy--; if(KEY_DOWN && (smy < (GFX_DISP_HEIGHT-16))) smy++; // Grafikanzeige aktualisieren gfx_draw_mode(GFX_DM_JAM2); // ueberschreiben gfx_move(GFX_DISP_WIDTH-32,0); gfx_vline(GFX_DISP_HEIGHT); draw_icon(ball_x,ball_y,xbm_ball8); draw_icon(smx,smy,smi); if((Audio_Status == PLAY)){ audio_play_song_P(0); // Ist das Lied weiter zuspielen? audio_show_titel_P(3,0,audio_start_titel_P(songnr)); } // audio_show_titel_P(3,30,audio_start_titel_P(songnr)); //**************************** TIMER2 ZEITANZEIGE char text3[12]=""; sprintf(text3, "TCNT2: %3d", (int)ISR_TCNT2_max); // gfx_move(50, 45); // gfx_set_proportional(1); // gfx_print_text("TCNT2:"); gfx_move(30, 55); gfx_set_proportional(0); gfx_print_text(text3); //***************************** HAUPTSCHLEIFE ZEITANZEIGE int16_t zyklus = pwm_timer_ms - old_time; if(zyklus < 0) zyklus += 1000; char text2[5]=""; sprintf(text2, "%2dms", (int)zyklus); gfx_move(100, 45); gfx_set_proportional(1); gfx_print_text("LOOP:"); gfx_move(100, 55); gfx_set_proportional(0); gfx_print_text(text2); // Zykluszeit aktualisieren (nach LCD Ausgabe) zyklus = pwm_timer_ms - old_time; if(zyklus < 0) zyklus += 1000; if(ZEITBASIS > zyklus){ delay(ZEITBASIS - zyklus); } } // while return 0 ; }; // main
Compiler results:
Werbung
Online
Andreasrlh
Bogdancmd
hunter94
jooenzogabrielfernand
josch
sadiebaum33713861245
violapfaff52895730
xwlerik344505932625