Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
843 Views

[Project][Galileo] Webbot for showing IndieDB stats

Hi,

I just finished my project for the Intel Galileo: a webbot, which shows the current statistics of an IndieDB (http://www.indiedb.com/ http://www.indiedb.com/) project.

General description:

The webbot loads IndieDB project sites every few seconds.

Then it parses the received HTML data and shows the website hits on the connected LCD display.

A multicolor LED is used to show the current status (e.g. shines blue, when data is parsed).

When a hitcounter has increased, a laser is activated to show that.

You can reset the laser by pressing button 5.

Button 1 is to show the current hitcounters.

Button 2 is to show the onboard temperatures of the Galileo.

Hardware:

  • Intel Galileo Gen 1
  • SainSmart LCD shield
  • multicolor LED
  • Laser module
  • Cables

The multicolor LED and the laser are connected to pin 11-13 (LED is 12+13, laser is 11) via ICSP port of the LCD display.

I soldered 2 cables together to use the ground connector of the port for both, the LED and the laser.

 

Software:

 

Here is the code:

// include the library code:

 

# include

 

# include

# define NO_KEY 0

 

# define UP_KEY 3

 

# define DOWN_KEY 4

 

# define LEFT_KEY 2

 

# define RIGHT_KEY 5

 

# define SELECT_KEY 1

// initialize the library with the numbers of the interface pins

 

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

int hitsMainLast = -1;

 

int hitsDemoLast = -1;

 

int hitsVideoLast = -1;

 

int mode = 0;

void setup() {

 

// set up the LCD's number of columns and rows:

 

lcd.begin(16, 2);

 

pinMode(11, OUTPUT);

 

pinMode(12, OUTPUT);

 

pinMode(13, OUTPUT);

 

digitalWrite(11, LOW);

 

digitalWrite(12, LOW);

 

digitalWrite(13, LOW);

 

}

void loop() {

// read values

 

int value1 = getQuarkTemp();

 

int value2 = getADCTemp();

int key = getKey();

// change mode

 

switch (key)

 

{

 

case 1:

 

mode = 0;

 

break;

 

case 2:

 

mode = 1;

 

break;

 

case 3:

 

break;

 

case 4:

 

break;

 

case 5:

 

digitalWrite(11, LOW);

 

break;

 

}

// get data from the internet

 

int hitsMain = GetHits("curl http://www.indiedb.com/games/nightork-adventures-beyond-the-moons-of-shadalee http://www.indiedb.com/games/nightork-adventures-beyond-the-moons-of-shadalee", "stats", 72, 77);

 

delay(500);

 

int hitsDemo = GetHits("curl http://www.indiedb.com/games/nightork-adventures-beyond-the-moons-of-shadalee/downloads/nightork-adv... http://www.indiedb.com/games/nightork-adventures-beyond-the-moons-of-shadalee/downloads/nightork-adv...", "Statistics", 163, 173);

 

delay(500);

 

int hitsVideo = GetHits("curl http://www.indiedb.com/games/nightork-adventures-beyond-the-moons-of-shadalee/videos http://www.indiedb.com/games/nightork-adventures-beyond-the-moons-of-shadalee/videos", "Statistics", 178, 188);

if (hitsMain != hitsMainLast || hitsDemo != hitsDemoLast || hitsVideo != hitsVideoLast)

 

{

 

digitalWrite(11, HIGH);

 

}

hitsMainLast = hitsMain;

 

hitsDemoLast = hitsDemo;

 

hitsVideoLast = hitsVideo;

// display text:

 

lcd.clear();

switch (mode)

 

{

 

case 0:

 

lcd.setCursor(0, 0);

 

lcd.print("NA:BMS");

 

lcd.setCursor(8, 0);

 

lcd.print("M:");

 

lcd.setCursor(10, 0);

 

lcd.print(hitsMain);

lcd.setCursor(0, 1);

 

lcd.print("D:");

 

lcd.setCursor(2, 1);

 

lcd.print(hitsDemo);

 

lcd.setCursor(8, 1);

 

lcd.print("V:");

 

lcd.setCursor(10, 1);

 

lcd.print(hitsVideo);

 

break;

case 1:

 

int qTemp = getQuarkTemp();

 

int adcTemp = getADCTemp();

lcd.setCursor(0, 0);

 

lcd.print("Q-T:");

 

lcd.setCursor(7, 0);

 

lcd.print(qTemp);

lcd.setCursor(0, 1);

 

lcd.print("ADC-T:");

 

lcd.setCursor(7, 1);

 

lcd.print(adcTemp);

 

break;

 

}

delay(2000);

 

}

// ===================================

 

// Read Hits

 

// ===================================

 

int GetHits(const char* url, const char* indicator, int first, int last)

 

{

 

// create buffer

 

char output[1000];

 

for (int i=0; i<1000; ++i)<p>  output[i] = 0;

// fetch

 

digitalWrite(12, HIGH);

 

...
0 Replies