Go Back   EcoModder Forum > EcoModding > Instrumentation > OpenGauge / MPGuino FE computer
Register Now
 Register Now
 

Reply  Post New Thread
 
Submit Tools LinkBack Thread Tools
Old 04-30-2008, 08:48 AM   #1 (permalink)
dcb
needs more cowbell
 
dcb's Avatar
 
Join Date: Feb 2008
Location: ÿ
Posts: 5,038

pimp mobile - '81 suzuki gs 250 t
90 day: 96.29 mpg (US)

schnitzel - '01 Volkswagen Golf TDI
90 day: 53.56 mpg (US)
Thanks: 158
Thanked 269 Times in 212 Posts
Just goofing off with formatted serial output (ANSI)

Remember Ansi?



Code:
int lbuttonPin = 17; // Left Button, on analog 3,  
int mbuttonPin = 18; // Middle Button, on analog 4 
int rbuttonPin = 19; // Right Button, on analog 5 

int lbuttonBit = 8; //  pin17 is a bitmask 8 on port C  
int mbuttonBit = 16; // pin18 is a bitmask 16 on port C  
int rbuttonBit = 32; // pin19 is a bitmask 32 on port C  

//pretend we start with upressed buttons
int buttonpins = lbuttonBit + mbuttonBit + rbuttonBit;

//attach the interrupt 
ISR( PCINT1_vect ){ 
  buttonpins &= PINC;//bypassing digitalRead for interrupt performance
} 
 
void setup() { 
  Serial.begin(9600);

  pinMode( lbuttonPin, INPUT ); 
  pinMode( mbuttonPin, INPUT ); 
  pinMode( rbuttonPin, INPUT ); 

//"turn on" the internal pullup resistors
  digitalWrite( lbuttonPin, HIGH); 
  digitalWrite( mbuttonPin, HIGH); 
  digitalWrite( rbuttonPin, HIGH); 

//low level interrupt enable stuff
  PCICR |= (1 << PCIE1); 
  PCMSK1 |= (1 << PCINT11); 
  PCMSK1 |= (1 << PCINT12); 
  PCMSK1 |= (1 << PCINT13);   
  Serial.print(27,BYTE);  Serial.print("[37;44m"); //white on blue
  clearScreen();
} 

void clearScreen(){
  Serial.print(27,BYTE);  Serial.print("[2J"); //ansi clear screen
  
//  draw a box in ascii
  Serial.print(0xc9,BYTE); for(int x=0;x<16;x++)  Serial.print(0xcd,BYTE);Serial.println(0xbb,BYTE);
  Serial.print(0xba,BYTE); Serial.print("                ");Serial.println(0xba,BYTE);
  Serial.print(0xba,BYTE); Serial.print("                ");Serial.println(0xba,BYTE);
  Serial.print(0xc8,BYTE); for(int x=0;x<16;x++)  Serial.print(0xcd,BYTE);Serial.println(0xbc,BYTE);
  gotoXY(0,0);
} 

//x=0..15, y=0..1
void gotoXY(int x, int y) {    
  Serial.print(27,BYTE);  Serial.print("[");Serial.print(y+2);
  Serial.print(";");Serial.print(x+2);Serial.print("H");
}
 
void print(char * text) {    
  Serial.print(text);
}
 
 
void loop() {    

  //print out what buttons have been pressed
  if(!(buttonpins&lbuttonBit)) {
    clearScreen();
    print("OpenGauge");
    gotoXY(9,1);
    print("MPGuino");
  }

  if(!(buttonpins&mbuttonBit)) {
    clearScreen();
    print("There's the ");
    gotoXY(0,1);
    print("middle button");
  }

  if(!(buttonpins&rbuttonBit)) {
    clearScreen();
    print("You found the");
    gotoXY(0,1);
    print("right button!!!!");
  }
 
  
  //reset the buttons
  buttonpins = lbuttonBit + mbuttonBit + rbuttonBit;

  delay(1000);
}

__________________
WINDMILLS DO NOT WORK THAT WAY!!!

Last edited by dcb; 12-21-2008 at 11:39 AM..
  Reply With Quote
Alt Today
Popular topics

Other popular topics in this forum...

   
Reply  Post New Thread






Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Content Relevant URLs by vBSEO 3.5.2
All content copyright EcoModder.com