Skip to content

Commit

Permalink
fix #6 allows to back out once keyboard or f/w is selected
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Didron committed Jul 2, 2019
1 parent d6009ef commit f109619
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 4 deletions.
1 change: 1 addition & 0 deletions ui/src/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export default function App(props) {
hasError={hasError}
step={step}
model={device.model}
resetState={resetState}
toggleLog={() => {
setToggleLog(!toggleLog);
}}
Expand Down
21 changes: 20 additions & 1 deletion ui/src/components/Footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ import ZSALogo from "../images/zsa-logo.png";
import ErgodoxLogo from "../images/ergodox-logo.svg";
import PlanckLogo from "../images/planck-logo.svg";

export default ({ appVersion, model, step, toggleLog, hasError }) => {
export default ({
appVersion,
model,
step,
toggleLog,
hasError,
resetState
}) => {
return (
<div className="footer">
<div className="title">KEYBOARD:</div>
Expand All @@ -18,6 +25,18 @@ export default ({ appVersion, model, step, toggleLog, hasError }) => {
src={model === 0 ? PlanckLogo : ErgodoxLogo}
/>
)}
{(step === 2 || step === 3) && (
<a
className="reset"
href="#reset"
onClick={e => {
e.preventDefault();
resetState();
}}
>
restart
</a>
)}
</div>
<div className="log-toggle" onClick={toggleLog}>
>_
Expand Down
9 changes: 8 additions & 1 deletion ui/src/css/wally.css
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,24 @@ body {
}

.footer .status {
align-items: center;
color: #FFFFFF;
display: flex;
flex: 1;
font-weight: bold;
margin-left: 16px;
flex: 1;
}

.footer .status .logo{
position: relative;
top: 1px;
}

.footer .status .reset{
margin-left: 10px;
color: #fff;
}

.footer .logo {
position: relative;
top: 1px;
Expand Down
7 changes: 6 additions & 1 deletion wally/dfu.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ func DFUFlash(path string, s *State) {

// Get the list of device that match TMK's vendor id
for {
// if the app is reset stop this goroutine and close the usb context
if s.Step != 3 {
s.Log("info", "App reset, interrupting the flashing process.")
return
}
s.Log("info", "Waiting for a DFU capable device")
devs, err := ctx.OpenDevices(func(desc *gousb.DeviceDesc) bool {
if desc.Vendor == gousb.ID(dfuVendorID) && desc.Product == gousb.ID(dfuProductID) {
Expand All @@ -152,7 +157,7 @@ func DFUFlash(path string, s *State) {
}
}()

if (err != nil && runtime.GOOS != "windows") {
if err != nil && runtime.GOOS != "windows" {
message := fmt.Sprintf("OpenDevices: %s", err)
s.Log("error", message)
return
Expand Down
8 changes: 7 additions & 1 deletion wally/teensy.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ func TeensyFlash(path string, s *State) {
// Loop until a keyboard is ready to flash
for {
s.Log("info", "Waiting for a DFU capable device")
// if the app is reset stop this goroutine and close the usb context
if s.Step != 3 {
s.Log("info", "App reset, interrupting the flashing process.")
return
}

devs, err := ctx.OpenDevices(func(desc *gousb.DeviceDesc) bool {
if desc.Vendor == gousb.ID(halfKayVendorID) && desc.Product == gousb.ID(halfKayProductID) {
return true
Expand All @@ -50,7 +56,7 @@ func TeensyFlash(path string, s *State) {
}
}()

if (err != nil && runtime.GOOS != "windows") {
if err != nil && runtime.GOOS != "windows" {
message := fmt.Sprintf("OpenDevices: %s", err)
s.Log("error", message)
return
Expand Down

0 comments on commit f109619

Please sign in to comment.