working now

Former-commit-id: 4ea0cf9e5dbdb0385e1e7eb2bfb89b1c4ba14719
master
Ondřej Hruška 9 years ago
parent f77caa03f2
commit c3d4fe39d0
  1. 2
      html/js/all.js
  2. 14
      html/pages/home.tpl
  3. 2
      html_src/_start.php
  4. 16
      html_src/js-src/page_home.js
  5. 2
      html_src/js/all.js
  6. 14
      html_src/page_home.php
  7. 4
      user/datalink.h
  8. 61
      user/page_home.c
  9. 2
      user/page_home.h
  10. 10
      user/routes.c
  11. 2
      user/sbmp_config.h
  12. 3
      user/user_main.c

File diff suppressed because one or more lines are too long

@ -23,17 +23,11 @@
<div id="content"> <div id="content">
<img src="/img/loader.gif" alt="Loading…" id="loader"> <img src="/img/loader.gif" alt="Loading…" id="loader">
<h1>Home</h1> <h1>Motor Control</h1>
<div class="Box"> <div class="Box center">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus cum eius molestias nesciunt nihil sequi? Laboriosam molestiae nesciunt <a class="button btn-blue" id="btn-rev">REV</a><span style="display:inline-block;width:2em"></span>
quis! Aut eius esse in laudantium obcaecati possimus quis repudiandae tenetur velit.</p> <a class="button btn-blue" id="btn-fwd">FWD</a>
</div>
<div class="Box">
<h2>Firmware</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus cum eius molestias nesciunt nihil sequi? Laboriosam molestiae nesciunt
quis! Aut eius esse in laudantium obcaecati possimus quis repudiandae tenetur velit.</p>
</div> </div>
<script> <script>

@ -1,7 +1,7 @@
<?php <?php
$prod = defined('STDIN'); $prod = defined('STDIN');
$root = $prod ? '' : 'http://192.168.1.13'; $root = $prod ? '' : 'http://192.168.1.15';
$menu = [ $menu = [
'home' => [ $prod ? '/home' : '/page_home.php', 'Home' ], 'home' => [ $prod ? '/home' : '/page_home.php', 'Home' ],

@ -4,7 +4,21 @@ var page_home = (function () {
/** Set up the Home page */ /** Set up the Home page */
home.init = function () { home.init = function () {
// $('#btn-fwd').on('mousedown', function() {
console.log('FWD down');
$().get(_root+'/m/start?dir=f');
}).on('mouseup', function() {
console.log('FWD up');
$().get(_root+'/m/stop');
});
$('#btn-rev').on('mousedown', function() {
console.log('REV down');
$().get(_root+'/m/start?dir=r');
}).on('mouseup', function() {
console.log('REV up');
$().get(_root+'/m/stop');
});
}; };
return home; return home;

File diff suppressed because one or more lines are too long

@ -1,17 +1,11 @@
<?php $page = 'home'; <?php $page = 'home';
include "_start.php"; ?> include "_start.php"; ?>
<h1>Home</h1> <h1>Motor Control</h1>
<div class="Box"> <div class="Box center">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus cum eius molestias nesciunt nihil sequi? Laboriosam molestiae nesciunt <a class="button btn-blue" id="btn-rev">REV</a><span style="display:inline-block;width:2em"></span>
quis! Aut eius esse in laudantium obcaecati possimus quis repudiandae tenetur velit.</p> <a class="button btn-blue" id="btn-fwd">FWD</a>
</div>
<div class="Box">
<h2>Firmware</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus cum eius molestias nesciunt nihil sequi? Laboriosam molestiae nesciunt
quis! Aut eius esse in laudantium obcaecati possimus quis repudiandae tenetur velit.</p>
</div> </div>
<script> <script>

@ -4,8 +4,8 @@
#include <esp8266.h> #include <esp8266.h>
#include <sbmp.h> #include <sbmp.h>
#define DG_MOTOR_HOME 40 #define DG_MOTOR_START 30
#define DG_MOTOR_GOTO 41 #define DG_MOTOR_STOP 31
// wifi status & control // wifi status & control
#define DG_SETMODE_AP 44 // request AP mode (AP button pressed) #define DG_SETMODE_AP 44 // request AP mode (AP button pressed)

@ -6,6 +6,67 @@
#include "serial.h" #include "serial.h"
httpd_cgi_state FLASH_FN cgiMotorStart(HttpdConnData *connData)
{
if (connData->conn == NULL) {
//Connection aborted. Clean up.
return HTTPD_CGI_DONE;
}
info("Motor start!");
int suc;
bool fwd = true;
uint32_t speed = 6144*2;
char buf[64];
suc = httpdFindArg(connData->getArgs, "dir", buf, 64);
if (suc != -1) {
fwd = (buf[0] == 'f'); // dir=f or dir=r
}
suc = httpdFindArg(connData->getArgs, "speed", buf, 64);
if (suc != -1) {
speed = (uint32_t)atoi(buf);
}
dbg("Speed = %d, rev = %d", speed, fwd);
sbmp_ep_start_message(dlnk_ep, DG_MOTOR_START, 5, NULL);
sbmp_ep_send_u8(dlnk_ep, fwd ? 1 : 0);
sbmp_ep_send_u32(dlnk_ep, speed);
httpdStartResponse(connData, 200);
httpdHeader(connData, "Content-Type", "text/json");
httpdEndHeaders(connData);
httpdSend(connData, "{\"success\":true}\n", -1);
return HTTPD_CGI_DONE;
}
httpd_cgi_state FLASH_FN cgiMotorStop(HttpdConnData *connData)
{
if (connData->conn == NULL) {
//Connection aborted. Clean up.
return HTTPD_CGI_DONE;
}
info("Motor stop!");
sbmp_ep_start_message(dlnk_ep, DG_MOTOR_STOP, 0, NULL);
httpdStartResponse(connData, 200);
httpdHeader(connData, "Content-Type", "text/json");
httpdEndHeaders(connData);
httpdSend(connData, "{\"success\":true}\n", -1);
return HTTPD_CGI_DONE;
}
/** "Home" page */ /** "Home" page */
httpd_cgi_state FLASH_FN tplHome(HttpdConnData *connData, char *token, void **arg) httpd_cgi_state FLASH_FN tplHome(HttpdConnData *connData, char *token, void **arg)
{ {

@ -4,5 +4,7 @@
#include <httpd.h> #include <httpd.h>
httpd_cgi_state tplHome(HttpdConnData *connData, char *token, void **arg); httpd_cgi_state tplHome(HttpdConnData *connData, char *token, void **arg);
httpd_cgi_state FLASH_FN cgiMotorStop(HttpdConnData *connData);
httpd_cgi_state FLASH_FN cgiMotorStart(HttpdConnData *connData);
#endif // PAGE_ABOUT_H #endif // PAGE_ABOUT_H

@ -14,7 +14,7 @@
#include "cgi_reset.h" #include "cgi_reset.h"
#include "cgi_ping.h" #include "cgi_ping.h"
#define WIFI_PROTECT 1 #define WIFI_PROTECT 0
#if WIFI_PROTECT #if WIFI_PROTECT
static int FLASH_FN myPassFn(HttpdConnData *connData, int no, char *user, int userLen, char *pass, int passLen); static int FLASH_FN myPassFn(HttpdConnData *connData, int no, char *user, int userLen, char *pass, int passLen);
@ -39,6 +39,10 @@ HttpdBuiltInUrl builtInUrls[] = {
ROUTE_CGI("/system/reset", cgiResetDevice), ROUTE_CGI("/system/reset", cgiResetDevice),
ROUTE_CGI("/system/ping", cgiPing), ROUTE_CGI("/system/ping", cgiPing),
// --- Motor ctrl ---
ROUTE_CGI("/m/start", cgiMotorStart),
ROUTE_CGI("/m/stop", cgiMotorStop),
// --- UI pages --- // --- UI pages ---
// System Status page // System Status page
ROUTE_REDIRECT("/", "/home"), ROUTE_REDIRECT("/", "/home"),
@ -87,8 +91,8 @@ static int FLASH_FN myPassFn(HttpdConnData *connData, int no, char *user, int us
(void)passLen; (void)passLen;
if (no == 0) { if (no == 0) {
os_strcpy(user, "wifiadmin"); os_strcpy(user, "admin");
os_strcpy(pass, "amazing grace"); os_strcpy(pass, "prasopes");
return 1; return 1;
//Add more users this way. Check against incrementing no for each user added. //Add more users this way. Check against incrementing no for each user added.
// } else if (no==1) { // } else if (no==1) {

@ -55,7 +55,7 @@
/** /**
* @brief Enable detailed logging (only for debugging, disable for better performance). * @brief Enable detailed logging (only for debugging, disable for better performance).
*/ */
#define SBMP_DEBUG 1 #define SBMP_DEBUG 0
// here are the actual logging functions // here are the actual logging functions

@ -125,7 +125,8 @@ void user_init(void)
banner_info("Ready"); banner_info("Ready");
printf(LOG_EOL); printf(LOG_EOL);
wificontrol_init(); // don't send updates
//wificontrol_init();
os_timer_disarm(&prSecondTimer); os_timer_disarm(&prSecondTimer);
os_timer_setfn(&prSecondTimer, prSecondTimerCb, NULL); os_timer_setfn(&prSecondTimer, prSecondTimerCb, NULL);

Loading…
Cancel
Save