Skip to content

Commit

Permalink
next version
Browse files Browse the repository at this point in the history
  • Loading branch information
rofthedeep committed Apr 27, 2015
1 parent 61ea97a commit c24d6f6
Show file tree
Hide file tree
Showing 13 changed files with 90 additions and 33 deletions.
23 changes: 16 additions & 7 deletions arduino/arduino_homerrr/arduino_homerrr.ino
Original file line number Diff line number Diff line change
@@ -1,28 +1,37 @@
String cmd;
int fullValue;
int pin;
int value;
int inorout;
void setup() {

Serial.begin(115200); // initialize serial communication
Serial.setTimeout(10);
Serial.print("Setup");
Serial.begin(9600); // initialize serial communication
Serial.setTimeout(100);
//pinMode(12, OUTPUT);
//pinMode(11, OUTPUT);
//Serial.print("Setup");
// Set delay so you don't have to opened the serial monitor to run the script
//delay(2000);
//pinMode(12, OUTPUT); // initialize the green LED pin as an output
//pinMode(11, OUTPUT); // initialize the red LED pin as an output
}
void loop() {
// see if there's incoming serial data:
if (Serial.available() > 0) {
//delay(10);
//fullValue = Serial.parseInt();
//Serial.println(fullValue);
pin = Serial.parseInt();
//pin = Serial.read();
Serial.print(pin);
//Serial.println(pin);
//value = Serial.parseInt();
value = Serial.parseInt();
Serial.print(value);
//Serial.println(value);
inorout = Serial.parseInt();
Serial.print(inorout);
//Serial.println(inorout);
if(inorout == 1) {
pinMode(pin, OUTPUT);
digitalWrite(pin,value);
analogWrite(pin,value);
} else {
pinMode(pin, INPUT);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
String cmd;
int fullValue;
int pin;
int value;
int inorout;
void setup() {

Serial.begin(9600); // initialize serial communication
Serial.setTimeout(100);
}
void loop() {
// see if there's incoming serial data:
if (Serial.available() > 0) {
//fullValue = Serial.parseInt();
//Serial.println(fullValue);
pin = Serial.parseInt();
//pin = Serial.read();
Serial.println(pin);
value = Serial.parseInt();
Serial.println(value);
inorout = Serial.parseInt();
Serial.println(inorout);
if(inorout == 1) {
pinMode(pin, OUTPUT);
analogWrite(pin,value);
} else {
pinMode(pin, INPUT);
}
//incomingByte = Serial.read(); // read the oldest byte in the serial buffer
//Preform the code to switch on or off the leds
//Serial.println();
//Serial.println("Serial Read");
//Serial.print("incomingByte", BIN);
//Serial.println();
//Serial.println(incomingByte, DEC);
//if (incomingByte == '0') {
//digitalWrite(ledPin13, HIGH); //If the serial data is 0 turn red LED on
}

}

8 changes: 4 additions & 4 deletions function.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
function button($name, $title, $pin, $value, $direction, $btnClass) {
$html = '';
$html .= '<a class="btn ' . $btnClass . '" ';
$html .= 'href="' . $_SERVER['PHP_SELF'] . '?pin=' . $pin . '?value='. $value . '?direction=' . $direction . '"';
$html .= 'href="' . $_SERVER['PHP_SELF'] . '?pin=' . $pin . '&value='. $value . '&direction=' . $direction . '"';
$html .= ' title="' . $title . '"';
$html .= '>';
$html .= $name;
Expand All @@ -18,15 +18,15 @@ function button($name, $title, $pin, $value, $direction, $btnClass) {

function dimmer($name, $title, $pin, $value, $direction, $btnClass) {
$rand = rand(0,10000);
$action = 'sendForm.php';
$action = $_SERVER['PHP_SELF'];
$html = '';
$html .= '<div class="dimmer">';
$html .= '<form action="' . $action .'">';
$html .= '<div class="input-group">';
//$html .= '<label for="' . $name . '">' . $name .'</label>';
$html .= '<input type="text" class="form-control hidden" id="' . $pin . $rand . '" name="pin" placeholder="Pin" value="' . $pin .'">';
$html .= '<input type="text" class="form-control hidden" id="' . $direction . $rand . '" name="direction" placeholder="Pin" value="' . $direction .'">';
$html .= '<input type="text" class="form-control hidden" id="' . $pin . $rand . '" name="pin" placeholder="Pin" value="' . $pin .'">';
$html .= '<input type="text" class="form-control" id="' . $name . $rand . '" name="value" placeholder="Wert" value="' . $value .'">';
$html .= '<input type="text" class="form-control hidden" id="' . $direction . $rand . '" name="direction" placeholder="Pin" value="' . $direction .'">';
$html .= '<span class="input-group-btn">';
$html .= '<button class="btn ' . $btnClass . '" type="submit">';
//$html .= 'href="' . $_SERVER['PHP_SELF'] . '?pin=' . $pin . '?value='. $value . '?direction=' . $direction . '"';
Expand Down
3 changes: 2 additions & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
Schlafzimmer
</div>
<h3>Dimmer</h3>
<?php echo dimmer('senden', 'Pin 11 on', 11, 255, 1, 'on'); ?>
<?php echo dimmer('senden 11', 'Pin 11 on', 11, 255, 1, 'on'); ?>
<?php echo dimmer('senden 12', 'Pin 11 on', 12, 255, 1, 'on'); ?>
</div>
</div>
</div>
Expand Down
13 changes: 8 additions & 5 deletions initSerial.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
<?php

//check the GET action var to see if an action is to be performed
if (isset($_GET['pin'])) {

//Load the serial port class
require("php_serial.class.php");
$serial = new phpSerial();
$serial->deviceSet("/dev/cu.usbmodem1421");
$serial->confBaudRate(115200);
$serial->confBaudRate(9600);
$serial->deviceOpen();
$pin = $_GET['pin'];
$value = $_GET['value'];
error_log($value);
$direction = $_GET['direction'];
// send values to arduino
$serial->sendMessage($pin,$value,$direction);
//error_log('get' . $pin . ' ' . $value . ' ' . $direction);
//$serial->sendMessage($pin . '?value=' . $value . '?direction=' . $direction);
$serial->sendMessage('A'.$pin .'B'.$value.'C'.$direction);
//$serial->sendMessage($value);
//Issue the appropriate command according to the Arduino source code 0=Green On, 1=Green Off, 2=Red On, 3=Red Off.

// close serial connection
$serial->deviceClose();
}
?>
2 changes: 1 addition & 1 deletion pages/snippets/bodyScript.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="<?php echo resourcePath('/js/homerrr.js'); ?>"></script>
<!--<script src="<?php echo resourcePath('/js/homerrr.js'); ?>"></script> -->

<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
Expand Down
2 changes: 1 addition & 1 deletion resources/css/app-min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion resources/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -1636,7 +1636,7 @@ img {
border-radius: 4px;
padding-left: 15px;
padding-right: 15px;
padding-top: 40px;
padding-top: 46px;
position: relative;
float: left;
width: 100%;
Expand Down
6 changes: 4 additions & 2 deletions resources/js/homerrr.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
jQuery(function () {
//Controller

var that = this;
jQuery('form', this.ctx).submit(function (ev) {
jQuery(this).find('.btn').addClass('loader');
//jQuery(this).find('.btn').addClass('loader');
jQuery.ajax({
type: jQuery(this).attr('method'),
url: jQuery(this).attr('action'),
data: jQuery(this).serialize(),
success: function (data) {
//alert('ok');
jQuery(this).find('.btn').removeClass('loader');
//jQuery(this).find('.btn').removeClass('loader');
}
});
ev.preventDefault();

});
});

2 changes: 1 addition & 1 deletion resources/less/globals.less
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ img {
border-radius: 4px;
padding-left: @Padding/2;
padding-right: @Padding/2;
padding-top: 40px;
padding-top: 46px;
position: relative;
float: left;
width: 100%;
Expand Down
17 changes: 9 additions & 8 deletions sendForm.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
<?php

//check the GET action var to see if an action is to be performed
if (isset($_GET['pin'])) {

//Load the serial port class
require("php_serial.class.php");
$serial = new phpSerial();
$serial->deviceSet("/dev/cu.usbmodem1421");
$serial->confBaudRate(115200);
$serial->confBaudRate(9600);
$serial->deviceOpen();
$pin = $_GET['pin'];
$value = $_GET['value'];
error_log($value);
$direction = $_GET['direction'];

error_log('get' . $pin . ' ' . $value . ' ' . $direction);
// send values to arduino
$serial->sendMessage($pin,$value,$direction);
//error_log('get' . $pin . ' ' . $value . ' ' . $direction);
//$serial->sendMessage($pin . '?value=' . $value . '?direction=' . $direction);
$serial->sendMessage('A'.$pin .'B'.$value.'C'.$direction);
//$serial->sendMessage($value);
//Issue the appropriate command according to the Arduino source code 0=Green On, 1=Green Off, 2=Red On, 3=Red Off.

// close serial connection
$serial->deviceClose();
}
?>
?>
2 changes: 1 addition & 1 deletion serialledcontrol.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
$serial->deviceSet("/dev/cu.usbmodem1421"); //SET THIS TO WHATEVER YOUR SERIAL DEVICE HAPPENS TO BE, YOU CAN FIND THIS UNDER THE ARDUINO SOFTWARE'S MENU

//Set the serial port parameters. The documentation says 9600 8-N-1, so
$serial->confBaudRate(115200); //Baud rate: 9600
$serial->confBaudRate(9600); //Baud rate: 9600
// $serial->confParity("none"); //Parity (this is the "N" in "8-N-1") ******THIS PART OF THE CODE WAS NOT NEEDED
// $serial->confCharacterLength(8); //Character length (this is the "8" in "8-N-1") ******THIS PART OF THE CODE WAS NOT NEEDED
// $serial->confStopBits(1); //Stop bits (this is the "1" in "8-N-1") ******THIS PART OF THE CODE WAS NOT NEEDED
Expand Down
2 changes: 1 addition & 1 deletion styleGuide/ressources/css/app-min.css

Large diffs are not rendered by default.

0 comments on commit c24d6f6

Please sign in to comment.