Skip to content

Commit 4214f4c

Browse files
committed
Implement echo state change in redux
1 parent af0c0a2 commit 4214f4c

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

src/constants/action-types.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ const actionTypes = {
44
SHOW_OVERLAY: 'SHOW_OVERLAY',
55
HIDE_OVERLAY: 'HIDE_OVERLAY',
66
DELETE_PROJECT_CONFIRM: 'DELETE_PROJECT_CONFIRM',
7+
ECHO_ON: 'ECHO_ON',
8+
ECHO_OFF: 'ECHO_OFF',
79
RX_ON: 'RX_ON',
810
RX_OFF: 'RX_OFF',
911
TX_ON: 'TX_ON',

src/creators/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ const creators = {
2222
transmit: require('./transmit'),
2323
updateDuration: require('./update-duration'),
2424
clearTransmission: require('./clear-transmission'),
25+
echoOn: require('./echo-on'),
26+
echoOff: require('./echo-off'),
2527
// device creators
2628
connect: require('./connect'),
2729
disconnect: require('./disconnect'),

src/plugins/handlers.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,21 @@ function handlers(app, opts, done){
482482
txOn();
483483
}
484484

485+
function toggleEcho(){
486+
const { device } = store.getState();
487+
const { echo } = consoleStore.getState();
488+
const { selected, connected } = device;
489+
if(selected && connected){
490+
const board = app.getBoard(selected);
491+
if(echo){
492+
consoleStore.dispatch(creators.echoOff());
493+
}else{
494+
consoleStore.dispatch(creators.echoOn());
495+
}
496+
board.setEcho(!echo);
497+
}
498+
}
499+
485500
function download() {
486501
const { device } = store.getState();
487502
const { selected } = device;
@@ -653,6 +668,7 @@ function handlers(app, opts, done){
653668
reloadDevices,
654669
selectDevice,
655670
download,
671+
toggleEcho,
656672
enableAutoDownload,
657673
disableAutoDownload
658674
});

src/plugins/rxtx.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ function applyStyles(el, stylesToApply){
5656
}
5757

5858
function rxtxBar(app, opts, done){
59+
const { toggleEcho } = app.handlers;
5960

6061
let bottomBar;
6162
let rx;
@@ -101,6 +102,8 @@ function rxtxBar(app, opts, done){
101102
echoLabel = document.createTextNode('Echo Off');
102103
echoContainer.appendChild(echoLabel);
103104

105+
echoContainer.addEventListener('click', toggleEcho, false);
106+
104107
const rxtxContainer = document.createElement('span');
105108
applyStyles(rxtxContainer, styles.rxtx);
106109
bottomBar.appendChild(rxtxContainer);

0 commit comments

Comments
 (0)