Skip to content

Commit

Permalink
Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lemairec committed Apr 15, 2017
1 parent ccf4a89 commit cff4ba2
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 27 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.pioenvs/*
*.DS_Store
*.swp
14 changes: 7 additions & 7 deletions lib/MP3Player_KT403A/MP3Player_KT403A.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,13 +300,13 @@ uint8_t QueryPlayStatus(void)
{
c[i] = mp3.read();
i++;
delay(1);
if (i == 10) break;
// Serial.print(" 0x");
// Serial.print(c[i], HEX);
delay(1);
if (i == 10) break;
// Serial.print(" 0x");
// Serial.print(c[i], HEX);
}
// Serial.println(" ");
// Serial.println(" ");

if(c[3] == 0x3C || c[3] == 0x3D || c[3] == 0x3E)
{
return 0;
Expand All @@ -315,4 +315,4 @@ uint8_t QueryPlayStatus(void)
{
return 1;
}
}
}
131 changes: 111 additions & 20 deletions src/rasika.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,18 @@ const byte EVENEMENT_PRESSE = 1;
const byte EVENEMENT_RELACHE = 2;



bool endOfSong(){
int a=mp3.read();
bool res = (a !=-1);
if(res){
Serial.println("end of song ");
Serial.println(a);
for(int i = 0; i < 10; ++i){
int a=mp3.read();
}
}
return res;
}


int lirePoussoirs()
Expand Down Expand Up @@ -88,23 +99,31 @@ void inde(){
analogWrite(BLUEPIN, 0);
analogWrite(GREENPIN,0);

SpecifyMusicPlay(1);
bool play = true;
// fade from red to yellow
for (int g = 0; g < 256; g++) {
analogWrite(GREENPIN, g);
delay(FADESPEED);
}
for( int i=0; i<nbrepet;i++){


// fade from red to yellow
for (int r = 0 ; r <150 ; r++) {
analogWrite(REDPIN, r);
while(play){
for (int g = 0; g < 256; g++) {
analogWrite(GREENPIN, g);
delay(FADESPEED);
}
for (int r = 150 ; r >0; r--) {
analogWrite(REDPIN, r);
delay(FADESPEED);
play = play && !endOfSong(); if(!play){ break; }
for( int i=0; i<nbrepet;i++){


// fade from red to yellow
for (int r = 0 ; r <150 ; r++) {
analogWrite(REDPIN, r);
delay(FADESPEED);
play = play && !endOfSong(); if(!play){ break; }
}
for (int r = 150 ; r >0; r--) {
analogWrite(REDPIN, r);
delay(FADESPEED);
play = play && !endOfSong(); if(!play){ break; }
}
}
play = play && !endOfSong(); if(!play){ break; }
}
analogWrite(REDPIN, 0);
analogWrite(BLUEPIN, 0);
Expand All @@ -122,19 +141,24 @@ void belgique(){
analogWrite(REDPIN, 200);
delay(500);

for( int i=0; i<nbrepet;i++){
SpecifyMusicPlay(2);
bool play = true;
while(play){
for (int g = 256; g >0; g--) {
analogWrite(GREENPIN, g);
delay(FADESPEED);
}
play = play && !endOfSong(); if(!play){ break; }
for (int r = 200; r<256; r++) {
analogWrite(REDPIN, r);
delay(FADESPEED);
}
play = play && !endOfSong(); if(!play){ break; }
for (int r = 256; r>200; r--) {
analogWrite(REDPIN, r);
delay(FADESPEED);
}
play = play && !endOfSong(); if(!play){ break; }
for (int g = 0; g < 256; g++) {
analogWrite(GREENPIN, g);
delay(FADESPEED);
Expand All @@ -146,17 +170,15 @@ void belgique(){
Serial.println("finbelgique");
}


void angleterre(){
Serial.println("angleterre");
analogWrite(REDPIN, 0);
analogWrite(BLUEPIN, 0);
analogWrite(GREENPIN,0);
analogWrite(WHITEPIN,0);
SpecifyMusicPlay(4);
int a=mp3.read();
for(int i= 0;i<39;i++){

bool play = true;
while(play){
analogWrite(REDPIN, 255);
analogWrite(BLUEPIN, 0);
delay(125);
Expand All @@ -167,6 +189,7 @@ void angleterre(){
analogWrite(GREENPIN,255);
analogWrite(WHITEPIN,255);
delay(125);
play = play && !endOfSong(); if(!play){ break; }
analogWrite(WHITEPIN,0);
analogWrite(REDPIN, 0);
analogWrite(BLUEPIN, 0);
Expand All @@ -178,6 +201,7 @@ void angleterre(){
delay(125);
analogWrite(BLUEPIN, 0);
delay(75);
play = play && !endOfSong(); if(!play){ break; }
}
delay(1000);
analogWrite(REDPIN, 125);
Expand Down Expand Up @@ -323,4 +347,71 @@ void loop(){
}

delay(3);
}
}





void setup2()
{
mp3.begin(9600);
Serial.begin(9600);
delay(100);

SelectPlayerDevice(0x02); // Select SD card as the player device.
SetVolume(0x0E); // Set the volume, the range is 0x00 to 0x1E.
}

void loop2()
{
char recvChar = 0;
while(Serial.available())
{
recvChar = Serial.read();
}
Serial.print("Send: ");
Serial.println( recvChar );

switch (recvChar)
{
case '1':
SpecifyMusicPlay(1);
Serial.println("Specify the music index to play");
break;
case '2':
PlayPause();
Serial.println("Pause the MP3 player");
break;
case '3':
PlayResume();
Serial.println("Resume the MP3 player");
break;
case '4':
PlayNext();
Serial.println("Play the next song");
break;
case '5':
PlayPrevious();
Serial.println("Play the previous song");
break;
case '6':
PlayLoop();
Serial.println("Play loop for all the songs");
break;
case '7':
IncreaseVolume();
Serial.println("Increase volume");
break;
case '8':
DecreaseVolume();
Serial.println("Decrease volume");
break;
default:
break;
}

delay(1000);

printReturnedData();
}
42 changes: 42 additions & 0 deletions vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env python

import sys, optparse, subprocess, urllib2, os, os.path, errno, zipfile, string, json, platform, shutil, tarfile, urlparse, tempfile, multiprocessing
from subprocess import Popen, PIPE
import argparse
import sys

def callWithoutPrint(cmdline):
ret = subprocess.call(cmdline, shell=True)
if ret != 0:
print >> sys.stderr, 'Running: ' + cmdline + ' failed with exit code ' + str(ret) + '!'
return ret

def call(cmdline):
print 'Running: ' + cmdline
callWithoutPrint(cmdline)


class VimExec(object):

def __init__(self):
parser = argparse.ArgumentParser( description='WeedVision');
parser.add_argument('command', help='Subcommand to run'
, choices=['vim_f5', 'vim_f6', 'vim_f7', 'vim_f8']);
args = parser.parse_args(sys.argv[1:2])
if not hasattr(self, args.command):
print 'Unrecognized command'
parser.print_help()
exit(1)
getattr(self, args.command)()



def vim_f5(self):
call('platformio run -t upload && platformio device monitor');

def vim_f6(self):
call('python test.py');


if __name__ == '__main__':
VimExec()

0 comments on commit cff4ba2

Please sign in to comment.