Code Monkey home page Code Monkey logo

fsr's People

Contributors

aeubanks avatar alex-ong avatar dependabot[bot] avatar dominick-peluso-bose avatar dominickp avatar feedbacker avatar joshhead avatar natano avatar robert40c avatar teejusb avatar uvcat7 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

fsr's Issues

Speed up AnalogRead() in pro micro / atmega platforms

I will make a PR as i am testing this on my own branch.

Related link
https://forum.arduino.cc/t/faster-analog-read/6604/6

fix is probably as simple as:

#define FASTADC 1

// defines for setting and clearing register bits
#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif
 
#if FASTADC
  // set prescale to 16. s == 1, x ==0 from prescale table.
  // 16 == 78000 hz, default is 128 which is 9600hz
  sbi(ADCSRA,ADPS2) ;
  cbi(ADCSRA,ADPS1) ;
  cbi(ADCSRA,ADPS0) ;
#endif
| Prescale | ADPS2 ADPS1 ADPS0 | Clock freq (MHz) | Sampling rate (KHz) |
|----------|-------------------|------------------|---------------------|
| 2        | 0 0 1             | 8                | 615                 |
| 4        | 0 1 0             | 4                | 307                 |
| 8        | 0 1 1             | 2                | 153                 |
| 16       | 1 0 0             | 1                | 76.8                |
| 32       | 1 0 1             | 0.5              | 38.4                |
| 64       | 1 1 0             | 0.25             | 19.2                |
| 128      | 1 1 1             | 0.125            | 9.6 (default)       |

Not getting realtime info on GUI

Hi, I followed all the steps but I can't see the threshold realtime bars and sometimes the profiles disappear.

Works fine but I can't check if the sensors had pressure by default

README pointing to wrong lines in "Firmware Setup"

In step 7 of the 'Firmware Setup' section of the readme, the hyperlink for the sensor array points here:

fsr/fsr.ino

Lines 204 to 209 in 365fed5

for (size_t i = 0; i < num_sensors_; ++i) {
if (individual_states_[i] == SensorState::ON) {
turn_on = true;
break;
}
}

where it should be pointing here:

fsr/fsr.ino

Lines 428 to 433 in 365fed5

Sensor kSensors[] = {
Sensor(A0),
Sensor(A1),
Sensor(A2),
Sensor(A3),
};

not super crucial but could be confusing

When serial port is not found, server uses a lot of CPU, even after stopping main process

Tested on macOS Big Sur 11.4

When the serial port is configured incorrectly or the device is not plugged in, I see an error like the following.

~/Documents/teejusb/fsr/webui $ yarn start-api
yarn run v1.22.17
$ cd server && venv/bin/python server.py
 * WebUI can be found at: http://192.168.1.67:5000
======== Running on http://0.0.0.0:5000 ========
(Press CTRL+C to quit)
Client connected
Found Profiles: ['']
Starting Read thread
Starting Write thread
Error opening serial: [Errno 2] could not open port /dev/ttyACM0: [Errno 2] No such file or directory: '/dev/ttyACM0'
Traceback (most recent call last):
  File "/Users/jheadapohl/Documents/teejusb/fsr/webui/server/venv/lib/python3.9/site-packages/serial/serialposix.py", line 265, in open
    self.fd = os.open(self.portstr, os.O_RDWR | os.O_NOCTTY | os.O_NONBLOCK)
FileNotFoundError: [Errno 2] No such file or directory: '/dev/ttyACM0'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/jheadapohl/Documents/teejusb/fsr/webui/server/server.py", line 179, in Open
    self.ser = serial.Serial(self.port, 115200, timeout=self.timeout)
  File "/Users/jheadapohl/Documents/teejusb/fsr/webui/server/venv/lib/python3.9/site-packages/serial/serialutil.py", line 240, in __init__
    self.open()
  File "/Users/jheadapohl/Documents/teejusb/fsr/webui/server/venv/lib/python3.9/site-packages/serial/serialposix.py", line 268, in open
    raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
serial.serialutil.SerialException: [Errno 2] could not open port /dev/ttyACM0: [Errno 2] No such file or directory: '/dev/ttyACM0'
Error opening serial: [Errno 2] could not open port /dev/ttyACM0: [Errno 2] No such file or directory: '/dev/ttyACM0'
Traceback (most recent call last):
  File "/Users/jheadapohl/Documents/teejusb/fsr/webui/server/venv/lib/python3.9/site-packages/serial/serialposix.py", line 265, in open
    self.fd = os.open(self.portstr, os.O_RDWR | os.O_NOCTTY | os.O_NONBLOCK)
FileNotFoundError: [Errno 2] No such file or directory: '/dev/ttyACM0'
...

This is fine and expected; it tells me the file for the serial port is missing. There are two problems though. First, the error is printed repeatedly as fast as the server process can go. Second, quitting the server with Ctrl+C does not stop the thread that is printing the errors, which makes the open terminal difficult to use and also makes my computer warmer (and noisier, as the fan ramps up). I can kill the leftover processes manually or close the terminal they are running in.

Ideally Ctrl+C should stop all the server processes, and separately it might be useful to add a delay when retrying the connection to the serial port.

Info file .EXE for Windows

hi, I wanted to ask if you will create an installation file for windows for the management of the FSR thresholds, in order to make it easier to manage the threshold change of each sensor, and if you increase the firmware for arduino, you will be able to configure the 16 sensors configuration that you can then possibly manage the calibration from a single program that can be installed on windows

UI working visually, but it seems to be not updating thresholds

I had the fsr working previously, but since my arduino collapsed, I had to reinstall it.

The UI works visually, you can visually set thresholds and the colors change when the pressure exceeds the thresholds. However, I cannot use the UI to change the interface. I have to open Arduino IDE and manually set the thresholds using the serial monitor there.

Any help or further questions would be appreciated. Thanks!

Profile names can't have spaces

When creating a profile with spaces, on next server restart the profile will fail to parse as it expects an exact number of space separated elements. This causes the profile to fail to load, and then the settings will get wiped when we attempt to next save the file.

We can migrate to a better representation for configuration (e.g. a JSON file) that does handle space separated strings as expected.

storing settings?

I set the thresholds on my laptop and then connect the arduino to a different system to play stepmania. But the thresholds don't stick, I have to either load up the API on the SM machine or hardcode them.

Can we use EEPROM to store the 4 values?

Arduino Keyboard library not supported for ATmega328P, ATmega1280 or ATmega2560

Thanks for providing this excellent code to the community.

Unless I'm missing something, the .ino won't compile for the ATmega328P, ATmega1280 or ATmega2560 as the Arduino "Keyboard" library isn't supported on chips that don't have native USB interfaces. The ATmega32U4 has a USB interface built on the chip itself and compiles fine.

aiohttp 3.7.4 isn't compatible with asyncio in Python 3.10

I mentioned this on Discord a couple of months ago, but have only just gotten back into hacking on the FSR code. This issue manifests as a TypeError in aiohttp when you hit ctrl-C to interrupt the script, like so:

yarn run v1.22.18
$ cd server && venv/bin/python server.py
/home/maybe/dev/fsr/fsr/webui/server/server.py:327: DeprecationWarning: There is no current event loop
  main_thread_loop = asyncio.get_event_loop()
 * WebUI can be found at: http://10.10.9.144:5000
Found Profiles: ['']
/home/maybe/dev/fsr/fsr/webui/server/server.py:208: DeprecationWarning: isSet() is deprecated, use is_set() instead
  while not thread_stop_event.isSet():
/home/maybe/dev/fsr/fsr/webui/server/server.py:252: DeprecationWarning: isSet() is deprecated, use is_set() instead
  while not thread_stop_event.isSet():
======== Running on http://0.0.0.0:5000 ========
(Press CTRL+C to quit)
Client connected
^CTraceback (most recent call last):
  File "/home/maybe/dev/fsr/fsr/webui/server/server.py", line 460, in <module>
    web.run_app(app, port=HTTP_PORT)
  File "/home/maybe/dev/fsr/fsr/webui/server/venv/lib64/python3.10/site-packages/aiohttp/web.py", line 512, in run_app
    _cancel_tasks({main_task}, loop)
  File "/home/maybe/dev/fsr/fsr/webui/server/venv/lib64/python3.10/site-packages/aiohttp/web.py", line 444, in _cancel_tasks
    asyncio.gather(*to_cancel, loop=loop, return_exceptions=True)
TypeError: gather() got an unexpected keyword argument 'loop'

Per aio-libs/aiohttp#5905, this just looks like the dependency in requirements.txt needs to be bumped. Installing the newer releases of aiohttp and async-timeout (>= 4.0 seems necessary) fixes the ^C issue, but causes something else to break silently so that sensor values don't get reported to the UI. The value bars and the time plot both sit at 0, even though I apply pressure to my test sensor.

No sure what the breakage with the value reporting is, if I work it out I'll follow up here or make another issue.

Link to discord group?

I see there's a note at the top of the write up pointing to a discord group. I don't see a link to get there and clicking on it simply shows the graphic for number of people online. Could a link to the group be added here?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.