-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from AllenShintani/edison-feature-56
Declarative ui is developed
- Loading branch information
Showing
81 changed files
with
163 additions
and
435 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// // edison.js | ||
// const { renderToString } = require('react-dom/server'); | ||
// const path = require('path'); | ||
// const { createRequire } = require('module'); | ||
|
||
// const run = async (filePath) => { | ||
// const require = createRequire(import.meta.url); | ||
// const absPath = path.resolve(filePath); | ||
// const { App } = require(absPath); | ||
|
||
// try { | ||
// const content = renderToString(<App />); | ||
// console.log(content); | ||
// } catch (error) { | ||
// console.error('Failed to render the app:', error); | ||
// } | ||
// }; | ||
|
||
// const filePath = process.argv[2]; | ||
// if (!filePath) { | ||
// console.error('Please provide a file path to run'); | ||
// process.exit(1); | ||
// } | ||
|
||
// run(filePath); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from 'react' | ||
import { Board } from './utils/Board' | ||
import { Led } from './factory/output/uniqueDevice/Led' | ||
import { renderToString } from 'react-dom/server' | ||
|
||
const App: React.FC = () => { | ||
return ( | ||
<Board port={'/dev/ttyUSB0'}> | ||
<Led pin={13} /> | ||
</Board> | ||
) | ||
} | ||
|
||
renderToString(<App />) | ||
export { App } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import type React from 'react' | ||
import { attachBuzzer } from '../../../../procedure/factory/output/uniqueDevice/buzzer' | ||
import { board } from '../../../../procedure/utils/board' | ||
import type { SerialPort } from 'serialport' | ||
|
||
type LEDProps = { | ||
pin: number | ||
isOn?: boolean | ||
blink?: number | ||
} | ||
|
||
export const Buzzer: React.FC<LEDProps> = ({ pin, isOn }) => { | ||
board.on('ready', (port: SerialPort) => { | ||
const buzzer = attachBuzzer(port, pin) | ||
|
||
if (isOn === true) { | ||
buzzer.on() | ||
} | ||
|
||
if (isOn === false) { | ||
buzzer.off() | ||
} | ||
}) | ||
|
||
return null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import type React from 'react' | ||
import { attachLed } from '../../../../procedure/factory/output/uniqueDevice/led' | ||
import { board } from '../../../../procedure/utils/board' | ||
import type { SerialPort } from 'serialport' | ||
|
||
type LEDProps = { | ||
pin: number | ||
isOn?: boolean | ||
blink?: number | ||
} | ||
|
||
export const Led: React.FC<LEDProps> = ({ pin, isOn, blink }) => { | ||
board.on('ready', (port: SerialPort) => { | ||
const led = attachLed(port, pin) | ||
|
||
if (isOn === true) { | ||
led.on() | ||
} | ||
|
||
if (isOn === false) { | ||
led.off() | ||
} | ||
|
||
if (blink) { | ||
led.blink(blink) | ||
} | ||
}) | ||
|
||
return null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React, { createContext } from 'react' | ||
import type { SerialPort } from 'serialport' | ||
import { board } from '../../procedure/utils/board' | ||
|
||
export const BoardContext = createContext<SerialPort | null>(null) | ||
|
||
type BoardProps = { | ||
children: React.ReactNode | ||
port: string | ||
} | ||
|
||
export const Board: React.FC<BoardProps> = ({ children, port }) => { | ||
board.connectManual(port) | ||
return <BoardContext.Provider value={null}>{children}</BoardContext.Provider> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
export { board } from './utils/board' | ||
export { attachLed } from './factory/output/uniqueDevice/led' | ||
export { attachBuzzer } from './factory/output/uniqueDevice/buzzer' | ||
export { attachPressureSensor } from './factory/analog/uniqueDevice/pressureSensor' | ||
export { attachServo } from './factory/servo/uniqueDevice/servo' | ||
export { board } from './procedure/utils/board' | ||
export { attachLed } from './procedure/factory/output/uniqueDevice/led' | ||
export { attachBuzzer } from './procedure/factory/output/uniqueDevice/buzzer' | ||
export { attachPressureSensor } from './procedure/factory/analog/uniqueDevice/pressureSensor' | ||
export { attachServo } from './procedure/factory/servo/uniqueDevice/servo' | ||
//export { attachUltrasonicSensor } from './factory/complex/ultrasonicSensor' | ||
export { attachRgbLed } from './factory/output/uniqueDevice/rgbLed' | ||
export { attachCollisionSensor } from './factory/input/uniqueDevice/collisionSensor' | ||
export { attachHallEffectSensor } from './factory/input/uniqueDevice/hallEffectSensor' | ||
export { attachButton } from './factory/input/uniqueDevice/pushButton' | ||
export { attachRgbLed } from './procedure/factory/output/uniqueDevice/rgbLed' | ||
export { attachCollisionSensor } from './procedure/factory/input/uniqueDevice/collisionSensor' | ||
export { attachHallEffectSensor } from './procedure/factory/input/uniqueDevice/hallEffectSensor' | ||
export { attachButton } from './procedure/factory/input/uniqueDevice/pushButton' | ||
//export { attachLineTracking } from './factory/input/uniqueDevice/lineTracking' | ||
export { attachOutput } from './factory/output/uniqueDevice/output' | ||
export { attachOutput } from './procedure/factory/output/uniqueDevice/output' | ||
//export { attachInfraredObstacleAvoidanceSensor } from './factory/input/uniqueDevice/infraredObstacleAvoidanceSensor' | ||
export { delay } from './utils/delay' | ||
export { delay } from './procedure/utils/delay' | ||
export { Board } from './declarative/utils/Board' | ||
export { Led } from './declarative/factory/output/uniqueDevice/Led' | ||
export { App } from './declarative/App' | ||
export { SerialPort } from 'serialport' |
5 changes: 3 additions & 2 deletions
5
src/factory/analog/analogPort.ts → src/procedure/factory/analog/analogPort.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...ory/input/uniqueDevice/collisionSensor.ts → ...ory/input/uniqueDevice/collisionSensor.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
...factory/input/uniqueDevice/flameSensor.ts → ...factory/input/uniqueDevice/flameSensor.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ry/input/uniqueDevice/hallEffectSensor.ts → ...ry/input/uniqueDevice/hallEffectSensor.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
...Device/infraredObstacleAvoidanceSensor.ts → ...Device/infraredObstacleAvoidanceSensor.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
...factory/input/uniqueDevice/knockSensor.ts → ...factory/input/uniqueDevice/knockSensor.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
...actory/input/uniqueDevice/lineTracking.ts → ...actory/input/uniqueDevice/lineTracking.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
...ry/input/uniqueDevice/photoInterrupter.ts → ...ry/input/uniqueDevice/photoInterrupter.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
...ory/input/uniqueDevice/pirMotionSensor.ts → ...ory/input/uniqueDevice/pirMotionSensor.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
3 changes: 0 additions & 3 deletions
3
src/factory/input/uniqueDevice/readSensor.ts → .../factory/input/uniqueDevice/readSensor.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
src/factory/input/uniqueDevice/tiltSensor.ts → .../factory/input/uniqueDevice/tiltSensor.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.