Skip to content

Commit

Permalink
🚀 support sdio and spi SD card
Browse files Browse the repository at this point in the history
  • Loading branch information
fiber-punk committed Mar 28, 2022
1 parent aa132a9 commit ab7ca74
Show file tree
Hide file tree
Showing 8 changed files with 434 additions and 142 deletions.
12 changes: 10 additions & 2 deletions Webpage/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,18 @@ label,input[type="file"]{
color: #fff;
}

label,input[type="text"]{
color: #fff;
#temp-bed{
color: #000;
}

#temp-head{
color: #000;
}

/* label,input[type="text"]{
color: #fff;
} */


.form,.form-group{
display: flex;
Expand Down
81 changes: 58 additions & 23 deletions Webpage/index.htm
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@
<div class="row">
<form class="form-inline">
<div class="form-group">
<label for="exampleInputName2">Hotend</label>
<label for="temp-head">Hotend</label>
<input type="text" class="form-control form-control1" id="temp-head" placeholder="195">
<button type="button" class="btn btn-default" id="set-head">Set</button>
</div>

<br/>
<br/>
<div class="form-group">
<label for="exampleInputEmail2">Hotbed</label>
<label for="temp-bed">Hotbed</label>
<input type="text" class="form-control form-control1" id="temp-bed" placeholder="50">
<button type="button" class="btn btn-default" id="set-bed">Set</button>
</div>
Expand All @@ -136,16 +136,21 @@
</div>
<hr/>
<div class="row">
<div class="col-xs-4">
<button class="btn btn-default" type="button" id="update-list">Update Filelist</button>
</div>

<div class="col-xs-4">
<button class="btn btn-default" type="button" id="release-sd">Unmount SD</button>
</div>
<div class="table-responsive">
<table class="table">
<tr>
<td class="active">
<button class="btn btn-default btn-block" type="button" id="update-list">Update Filelist</button>
</td>
<td class="active">
<button class="btn btn-default btn-block" type="button" id="release-sd">Unmount SD</button>
</td>

<div class="col-xs-4">
<button class="btn btn-default" type="button" id="get-sd">Mount SD</button>
<td class="active">
<button class="btn btn-default btn-block" type="button" id="get-sd">Mount SD</button>
</td>
</tr>
</table>
</div>

</div>
Expand Down Expand Up @@ -195,25 +200,55 @@
<br/>


<hr>
<button class="btn btn-default" type="button" id="btn-pause">Pause</button>
<button class="btn btn-default" type="button" id="btn-cancle">Cancle</button>
<button class="btn btn-default" type="button" id="btn-restart">ResetESP</button>
<button class="btn btn-default" type="button" id="btn-resethost">GetPrinter</button>
<hr>

<div class="row">
<div class="table-responsive">
<table class="table">
<tr>
<td class="active">
<button class="btn btn-default btn-block" type="button" id="btn-pause">Pause</button>
</td>

<td class="active">
<button class="btn btn-default btn-block" type="button" id="btn-cancle">Cancle</button>
</td>

<td class="active">
<button class="btn btn-default btn-block" type="button" id="btn-restart">Resume</button>
</td>
</tr>

<tr>
<td class="active">
<button class="btn btn-default btn-block" type="button" id="btn-resethost">GetPrinter</button>
</td>

<td class="active">
<button class="btn btn-default btn-block" type="button" id="btn-setsdio">SetSDIO</button>
</td>

<td class="active">

<button class="btn btn-default btn-block" type="button" id="btn-setspi">SetSPI</button>
</td>
</tr>
</table>
</div>
</div>


<br/>
<div>
<label for="gcode-lineedit">Gcode</label>
<input type="text" class="btn btn-default" id="gcode-lineedit" placeholder="G28">
<div class="row">
<label for="gcode-lineedit">Gcode</label>
<input type="text" class="btn btn-default" id="gcode-lineedit" placeholder="G28">

<button type="button" class="btn btn-default" id="btn-send-gcode">Send</button>
<button type="button" class="btn btn-default" id="btn-send-clear">Clear</button>
<button type="button" class="btn btn-default" id="btn-send-gcode">Send</button>
<button type="button" class="btn btn-default" id="btn-send-clear">Clear</button>

</div>
<br/>
<br/>
<div>
<div class="row">
<textarea class="form-control" rows="12" id="serial-console"></textarea>
</div>

Expand Down
46 changes: 42 additions & 4 deletions Webpage/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ uploadButton.onclick = () => {
if(input.files.length === 0){
return;
}
var fileListM = document.getElementById("file-list-frame");
while(fileListM.hasChildNodes()){
fileListM.removeChild(fileListM.lastChild)
}
xmlHttp = new XMLHttpRequest();
// xmlHttp.onreadystatechange = httpPostProcessRequest;
xmlHttp.onload = uploadComplete;
Expand Down Expand Up @@ -269,8 +273,10 @@ source.addEventListener('gcode_cli', function(e) {
var reg_t = /T:([0-9]*\.[0-9]*) *\/([0-9]*\.[0-9]*)/g;
var reg_b = /B:([0-9]*\.[0-9]*) *\/([0-9]*\.[0-9]*)/g;
var reg_p = /SD printing byte ([0-9]*)\/([0-9]*)/g;
var reg_af = /Current file:([\S\s]*).GCO/g;
var reg_f = /Current file:([\S\s]*).GCO ([\S\s]*).gcode/g;
var reg_f = /Current file:([\S\s]*).GCO/g;
var reg_af = /Current file:([\S\s]*).GCO ([\S\s]*).gcode/g;
var reg_prusa = /:([\S\s]*).gcode/g;
var reg_short_low = /:([\S\s]*).gco/g;
var reg_end = /Finish/g;

var heater = obj.match(reg_t);
Expand Down Expand Up @@ -313,6 +319,19 @@ source.addEventListener('gcode_cli', function(e) {
printFileElement.innerHTML = RegExp.$2 + ".gcode";
}


var print_prusa_short = obj.match(reg_short_low);
if(print_prusa_short){
var printFileElement = document.getElementById("print-file");
printFileElement.innerHTML = RegExp.$1 + ".GCO";
}

var print_prusa_name = obj.match(reg_prusa);
if(print_prusa_name){
var printFileElement = document.getElementById("print-file");
printFileElement.innerHTML = RegExp.$1 + ".gcode";
}

var b_finish = obj.match(reg_end);
var b_done = obj.match(/Done/g);
if(b_finish || b_done){
Expand Down Expand Up @@ -380,6 +399,8 @@ const pauseButton = document.getElementById("btn-pause");
const cancleButton = document.getElementById("btn-cancle");
const restartButton = document.getElementById("btn-restart");
const resethostButton = document.getElementById("btn-resethost");
const setSPIButton = document.getElementById("btn-setspi");
const setSDIOButton = document.getElementById("btn-setsdio");

xpButton.onclick = () => {
var step = getRadioValue();
Expand Down Expand Up @@ -498,7 +519,7 @@ cancleButton.onclick = () => {
}

restartButton.onclick = () => {
var tt_url = "/esprestart";
var tt_url = "/operate?op=RECOVER";
xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", tt_url);
xmlHttp.send();
Expand All @@ -509,4 +530,21 @@ resethostButton.onclick = () => {
xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", tt_url);
xmlHttp.send();
}
}

setSPIButton.onclick = () => {
alert("After switching the SD data reading method, please must repower your Node and 3D printer.");
var tt_url = "/setsdtype?type=SPI";
xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", tt_url);
xmlHttp.send();
}


setSDIOButton.onclick = () => {
alert("After switching the SD data reading method, please must repower your Node and 3D printer.");
var tt_url = "/setsdtype?type=SDIO";
xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", tt_url);
xmlHttp.send();
}
3 changes: 3 additions & 0 deletions WifiNode/nodeconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ bool rst_usb = false;
bool paused_for_user = false;
bool paused_for_filament = false;

//printer sd type: 0==spi 1==sdio
uint8_t printer_sd_type = 1;
unsigned char current_usb_status = 0;
unsigned char pre_usb_status = 0;

Expand All @@ -46,6 +48,7 @@ void writeLog(String log_txt)
{
// if(g_status==PRINTING)
{
events.send(log_txt.c_str(), "gcode_cli");
sendHttpMsg(log_txt);
}
}
Expand Down
7 changes: 4 additions & 3 deletions WifiNode/nodeconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <SPI.h>
#include <Wire.h>
#include <Arduino.h>
#include <SD.h>
#include <SD_MMC.h>
#include <FS.h>
#include <EEPROM.h>
Expand All @@ -20,7 +21,7 @@
#include "crc8.h"
#include "FiberPunk_SSD1306.h"

#define VERSION "2022-3-15-2001"
#define VERSION "2022-3-27-2002"
#define DBG_OUTPUT_PORT Serial
#define PRINTER_PORT Serial
#define RED_LED 26
Expand All @@ -33,8 +34,6 @@
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32



enum OP_STATUS
{
P_IDEL=0,
Expand Down Expand Up @@ -75,13 +74,15 @@ extern ERROR_CODE g_error;
extern bool time_out;



extern bool hasSD;
extern bool recv_ok;
extern bool recvl_ok;
extern bool rst_usb;
extern bool paused_for_user;
extern bool paused_for_filament;

extern uint8_t printer_sd_type;
extern uint8_t cmd_length;

extern unsigned char current_usb_status;
Expand Down
5 changes: 3 additions & 2 deletions WifiNode/printerprocess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ void readPrinterBack()
{
writeLog(cf_node_name+":"+inData);
// writeLog(inData);
events.send(inData.c_str(), "gcode_cli");

if(inData.indexOf("setusb")!=-1)
{
rst_usb = true;
if (g_status!=PRINTING)
rst_usb = true;
}
//check temp
if (inData.indexOf("T:")!=-1)
Expand Down
Loading

0 comments on commit ab7ca74

Please sign in to comment.