Franky Modo

Nombre de messages : 736 Age : 36 Localisation : Grenoble Date d'inscription : 04/05/2007
![[Effet] H.A.Z.E. - HyperPhaser Empty](https://2img.net/i/empty.gif) | |
dav_ Team supporter


Nombre de messages : 367 Age : 33 Localisation : Geneve Date d'inscription : 24/05/2007
![[Effet] H.A.Z.E. - HyperPhaser Empty](https://2img.net/i/empty.gif) | Sujet: Re: [Effet] H.A.Z.E. - HyperPhaser Mar 10 Juin 2008 - 14:27 | |
| Hello, il fait bientôt tout t'on arduino  Bah des que tu commence et que tu as des photos ou vidéo poste les vite ici !!! | |
|
Franky Modo

Nombre de messages : 736 Age : 36 Localisation : Grenoble Date d'inscription : 04/05/2007
![[Effet] H.A.Z.E. - HyperPhaser Empty](https://2img.net/i/empty.gif) | Sujet: Re: [Effet] H.A.Z.E. - HyperPhaser Mar 10 Juin 2008 - 15:30 | |
| Vouais, la je suis en train de m'apercevoir que tous les pins sont utilisés.. C'était de justesse, tant pis pour le contrôle MIDI, me faudra une puce plus grande.. Faut dire les 8 pins du séquenceur bouffent pas mal de place.. | |
|
Franky Modo

Nombre de messages : 736 Age : 36 Localisation : Grenoble Date d'inscription : 04/05/2007
![[Effet] H.A.Z.E. - HyperPhaser Empty](https://2img.net/i/empty.gif) | Sujet: Re: [Effet] H.A.Z.E. - HyperPhaser Sam 14 Juin 2008 - 15:28 | |
| - Spoiler:
- Code:
-
/************************************ * CODE SOURCE DU HAZE * * Auteur: Franky * License: Copyleft * Date: 12/06/08 * Version: 1.0 * Build: 1D8E * ************************************/
/* Préprocesseur: */ #include <EEPROM.h> #define ExprTreshold 5000 #define rate 9600 #define AMPLITUDE 255 #define OFFSET 0 #define PAS 512 #define RFG_MIN 0 #define RFG_MAX 1023
/* Préprocesseur LCD: */ #define numRows 2 #define numCols 16
#define SPECIAL_CONTROL 0x7C #define DISPLAY_CONTROL 0xFE #define CLEAR 0x01 #define CURSOR_RIGHT 0x14 #define CURSOR_LEFT 0x10 #define SCROLL_RIGHT 0x1C #define SCROLL_LEFT 0x18 #define DISPLAY_ON 0x0C #define DISPLAY_OFF 0x08 #define UNDERLINE_CURSOR_ON 0x0E #define UNDERLINE_CURSOR_OFF 0x0C #define BLINK_CURSOR_ON 0x0D #define BLINK_CURSOR_OFF 0x0C #define SET_POSITION 0x80
/* Mapping des ports: NC = 0; RX LCD = 1; TX modePin = 2; IT exprPin = 3; IT s1Pin = 4; SQ s2Pin = 5; SQ s3Pin = 6; SQ s4Pin = 7; SQ s5Pin = 8; SQ outPin = 9; PW s6Pin = 10; SQ s7Pin = 11; SQ s8Pin = 12; SQ NC = 13; LED */
// Analog In: int rfgPin = 0; int spdPin = 1;
// PWM out: int outPin = 9;
// Interrupts: int modePin = 2; int exprPin = 3;
// Sequencer: int s1Pin = 4; int s2Pin = 5; int s3Pin = 6; int s4Pin = 7; int s5Pin = 8; int s6Pin = 10; int s7Pin = 11; int s8Pin = 12; int seqtab[8] = {s1Pin,s2Pin,s3Pin,s4Pin,s5Pin,s6Pin,s7Pin,s8Pin};
/* Variables globales: */ volatile char mode = 1; // Les valeurs seront écrasées par memread() volatile char expr = LOW; volatile char TT = 0; // Etat du TapTempo int speed; // Valeur du potard de vitesse int* adspeed = &speed; // Adresse de la vitesse int RFG; // Valeur de la pédale d'expression int step = 0; // Step en cours (-1 : seek désactivé ; range 0-7) int risefall = 0; // Montée ou descente du LFO, 0 = montée, 1 = descente int LFO = 0; // Compteur du LFO double sine; // Valeur du LFO int tap; // Compteur de taps (mode TT) unsigned long time[2] = {0,0}; // Mémoire du temps char splash_active = 1;
/* Fonctions LCD: */ void disablesplash() { if (splash_active) { Serial.print(SPECIAL_CONTROL, BYTE); Serial.print(9, BYTE); splash_active = 0; } return; }
void enablesplash() { if (!splash_active) { Serial.print(SPECIAL_CONTROL, BYTE); Serial.print(9, BYTE); splash_active = 1; } return; }
void setsplash() { lcdinit(); prints(" H.A.Z.E. ",0,0); prints(" HyperPhaser ",1,0); Serial.print(SPECIAL_CONTROL, BYTE); Serial.print(10, BYTE); clearlcd(); enablesplash(); }
void lcdinit() { sendControl(DISPLAY_ON); clearlcd(); brightness(100); }
void prints(const char *s, int line, int col) { cursor(line, col); Serial.print(s); }
void printnum(int num, int line, int col) { char buf[7]; int l; // Nombre de caractères à afficher if (num < 10) { l=1; } else { if (num < 100) { l=2; } else { if (num < 1000) { l=3; } else { if (num < 10000) { l=4; } else { l=5; } } } } cursor(line, col+(5-l)); Serial.print(itoa(num,buf,10)); }
void cursor(int line, int col) { line %= numRows; col %= numCols; int offset = ((line%2)*64) + (line >1 ? 20 : 0); sendControl((char)(offset + col + 128)); delay(10); }
void sendControl(char c) { Serial.print((char)DISPLAY_CONTROL); Serial.print(c); }
void brightness(int pct) { int level = (pct > 100 ? pct % 100 : pct); float brightness = (((float)level)/100) * 29 + 128; Serial.print((char)SPECIAL_CONTROL); Serial.print((char)brightness); // wait for the long string to be sent delay(5); }
void clearlcd() { sendControl(CLEAR); }
void affichage() { clearlcd(); prints("Mode: ",0,0); switch (mode) { case 0: prints("Sequence ",0,6); prints("Speed :",1,0); printnum(speed,1,7); prints("ms",1,14); break; case 1: prints("Manual ",0,6); prints("Expression ON ",1,0); break; case 2: prints("Automatic ",0,6); prints("Speed :",1,0); printnum(speed,1,7); prints("ms",1,14); break; default: break; } } /* Fonctions: */ void memwrite() { /* Adresses en EEPROM: mode: 0 expr: 1 TT: 2 speed: 3,4,5,6 */ EEPROM.write(0,(byte)mode); EEPROM.write(1,(byte)expr); for (int p=0;p<4;p++) { EEPROM.write(2+p,*(adspeed+p)); } return; }
void memread() { mode = EEPROM.read(0); expr = EEPROM.read(1); char speedA,speedB,speedC,speedD; speedA = EEPROM.read(2); speedB = EEPROM.read(3); speedC = EEPROM.read(4); speedD = EEPROM.read(5); speed = (speedA << 24) + (speedB << 16) + (speedC << 8) + speedD; return; }
void resettime() { time[0] = 0; time[1] = 0; return; }
void readrfg() { RFG = analogRead(rfgPin); map(RFG,RFG_MIN,RFG_MAX,0,1023); }
void speedcalc() { /* Enregistre dans la variable globale speed la vitesse en ms de traitement du bouzin. Fréquence du LFO: 0.1 Hz à 20Hz -> speed = 10 000 à 50 */ speed = analogRead(spdPin); if (expr) { readRFG(); map(RFG,0,1023,-32,32); speed += RFG; constrain(speed,0,1023); } map(speed,0,1023,50,10000); return; } void automode() { // Forme d'onde: sinus (LFO++)%PAS; sine = (((1+sin((LFO*TWO_PI)/PAS))/2)*AMPLITUDE)+OFFSET; analogWrite(outPin, sine); speedcalc(); delay(speed/PAS); }
void seekmode() { speedcalc(); digitalWrite(seqtab[step], HIGH); delay(speed); digitalWrite(seqtab[step], LOW); step = (step++)%8; //reset en 8 return; }
void resetseek() { for (int i=0; i<8;i++) { digitalWrite(seqtab[i], LOW); } return; }
void manmode() { RFG = analogRead(rfgPin); analogWrite(outPin, RFG/4); return; }
/* Interruptions: */ void IT0() { // Interruptions du switch MODE: /* On n'active l'IT que si le TT est inactif, pour éviter les changements de mode accidentels On reset la sortie si on passe en seek On reset le seek si on passe en sortie */ if (!TT) { if (mode == 0) analogWrite(outPin, 0); if (mode == 1) resetseek(); mode = (mode++)%3; } return; }
void IT1() { // Interruptions du switch EXPR: long hold = 0; while(digitalRead(exprPin)) { hold++; } /* A ce point, on vient de relâcher le switch On teste si c'est un court ou un long */ if (hold >= ExprTreshold) { // entrée/sortie du mode TT TT = !TT; tap = -1; resettime(); prints("TapTempo ",0,0); if (TT) prints("ON ",0,10); else prints("OFF ",0,10); return; // On quitte direct } else { // Tap court, TT ou pas? if (TT) { // On compte taptempo(); return; } else { prints("Expression ",0,0); expr = !expr; if (expr) prints("ON ",0,11); else prints("OFF ",0,11); return; } } }
void taptempo() { tap++; if (tap) { time[1] = millis(); if ( (time[1]-time[0]) > 5000) { // On a pas appuyé la 2e fois, reset. resettime(); tap = -1; return; } speed = time[1]-time[0]; prints("Speed:",1,0); printnum(speed,1,7); prints("ms",1,14); resettime(); tap = -1; return; } time[tap] = millis(); return; }
/* Fonctions de l'Arduino */ void setup() { for (int i=0;i<8;i++) { pinMode(seqtab[i], OUTPUT); } pinMode(modePin, INPUT); attachInterrupt(0,IT0,RISING); pinMode(exprPin, INPUT); attachInterrupt(1,IT1,RISING); pinMode(outPin, OUTPUT); Serial.begin(rate); lcdinit(); /* Fonctions spéciales:
A lancer au premier upload: setsplash();
Ne pas lancer cette fonction au premier upload memread(); */ }
void loop() { affichage(); memwrite(); switch (mode) { case 0: automode(); break; case 1: seekmode(); break; case 2: manmode(); break; default: break; } }
Si c'est concluant, j'ai de quoi rajouter une entrée MIDI pour le contrôle..  | |
|
Monsieur Arsène Team supporter


Nombre de messages : 123 Age : 36 Localisation : Palambier Date d'inscription : 04/05/2007
![[Effet] H.A.Z.E. - HyperPhaser Empty](https://2img.net/i/empty.gif) | Sujet: Re: [Effet] H.A.Z.E. - HyperPhaser Jeu 19 Juin 2008 - 16:24 | |
| j'ai aussi hâte de voir ça , niveau construction aussi ![[Effet] H.A.Z.E. - HyperPhaser 104680](/users/4111/60/36/74/smiles/104680.gif) | |
|