Title: Gyro sensor never reads negative · Issue #739 · ev3dev-lang-java/ev3dev-lang-java · GitHub
Open Graph Title: Gyro sensor never reads negative · Issue #739 · ev3dev-lang-java/ev3dev-lang-java
X Title: Gyro sensor never reads negative · Issue #739 · ev3dev-lang-java/ev3dev-lang-java
Description: Writing code to demo the gyro sensor was really straightforward thanks to the examples. However, the sensor never reads negative and I don't see a way to set the initial value (to some large multiple of 360). This is a dire problem when ...
Open Graph Description: Writing code to demo the gyro sensor was really straightforward thanks to the examples. However, the sensor never reads negative and I don't see a way to set the initial value (to some large multip...
X Description: Writing code to demo the gyro sensor was really straightforward thanks to the examples. However, the sensor never reads negative and I don't see a way to set the initial value (to some large mu...
Opengraph URL: https://github.com/ev3dev-lang-java/ev3dev-lang-java/issues/739
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Gyro sensor never reads negative","articleBody":"Writing code to demo the gyro sensor was really straightforward thanks to the examples. However, the sensor never reads negative and I don't see a way to set the initial value (to some large multiple of 360).\r\n\r\nThis is a dire problem when turning left. Is there a work-around I haven't found?\r\n\r\n\r\n(Code is in Scala - it may look strange, but does exactly what you think it does.)\r\n```\r\nimport ev3dev.actuators.LCD\r\nimport ev3dev.actuators.ev3.EV3Led\r\nimport ev3dev.sensors.EV3Key\r\nimport ev3dev.sensors.ev3.EV3GyroSensor\r\nimport lejos.hardware.{Key, KeyListener}\r\nimport lejos.hardware.lcd.GraphicsLCD\r\nimport lejos.hardware.port.SensorPort\r\n\r\nobject WatchGyro {\r\n def main(args: Array[String]):Unit = {\r\n watchGyro()\r\n }\r\n\r\n def watchGyro(): Unit = {\r\n\r\n //Set status lights to red\r\n val leftLed = new EV3Led(EV3Led.LEFT)\r\n val rightLed = new EV3Led(EV3Led.RIGHT)\r\n leftLed.setPattern(2) //red \r\n rightLed.setPattern(3) //yellow - can they really be different colors? cool!\r\n\r\n val lcd = LCD.getInstance()\r\n\r\n val gyroSensor = new EV3GyroSensor(SensorPort.S2)\r\n val gyroSampleProvider = gyroSensor.getAngleMode\r\n val gyroArray = new Array[Float](gyroSensor.sampleSize())\r\n\r\n var keepGoing = true\r\n\r\n val anyButton = new EV3Key(EV3Key.BUTTON_ALL)\r\n val anyButtonListener = new KeyListener {\r\n override def keyPressed(k: Key): Unit = ()\r\n\r\n override def keyReleased(k: Key): Unit = {\r\n keepGoing = false\r\n }\r\n }\r\n anyButton.addKeyListener(anyButtonListener)\r\n \r\n do {\r\n gyroSampleProvider.fetchSample(gyroArray,0)\r\n //Write the gyro value to the display\r\n lcd.setColor(GraphicsLCD.WHITE)\r\n lcd.fillRect(0, 0, lcd.getWidth, lcd.getHeight)\r\n lcd.setColor(GraphicsLCD.BLACK)\r\n lcd.drawString(s\"${gyroArray(0)}\", 0, 25, 0)\r\n lcd.refresh()\r\n\r\n System.out.println(s\"${gyroArray(0)}\")\r\n } while (keepGoing)\r\n\r\n //Set status lights to green\r\n leftLed.setPattern(1) //green\r\n rightLed.setPattern(1)\r\n }\r\n}\r\n```","author":{"url":"https://github.com/dwalend","@type":"Person","name":"dwalend"},"datePublished":"2020-10-12T03:18:31Z","url":"https://github.com/ev3dev-lang-java/ev3dev-lang-java/issues/739"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:5025a241-8150-658e-455d-6bc9d306965f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B99A:34A55:9C3D4D:E0A76D:6AFD8D51 |
| html-safe-nonce | 64a1043ec6a464ad3ff5a60f253f3f28cc29d6e22d5f66c980dba4656d67dc25 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOTlBOjM0QTU1OjlDM0Q0RDpFMEE3NkQ6NkFGRDhENTEiLCJ2aXNpdG9yX2lkIjoiNTEzODA3NjQzNDYzMTA2OTAwOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | c59bf8ab29b5bd3c6fdd5b77edadfc6a0caba48ebfd56ac4055e242c5bb58377 |
| hovercard-subject-tag | issue:719008173 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/ev3dev-lang-java/ev3dev-lang-java/739/issue_layout |
| twitter:image | https://opengraph.githubassets.com/75e4503a672c446be29ecfe83bf7296714f80ffa43af476852edb62910f8fa48/ev3dev-lang-java/ev3dev-lang-java/issues/739 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/75e4503a672c446be29ecfe83bf7296714f80ffa43af476852edb62910f8fa48/ev3dev-lang-java/ev3dev-lang-java/issues/739 |
| og:image:alt | Writing code to demo the gyro sensor was really straightforward thanks to the examples. However, the sensor never reads negative and I don't see a way to set the initial value (to some large multip... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dwalend |
| hostname | github.com |
| expected-hostname | github.com |
| None | bc86424ef34a73b386237872800e922d149d65ba907f63d6f150a2dcb8433bea |
| turbo-cache-control | no-preview |
| go-import | github.com/ev3dev-lang-java/ev3dev-lang-java git https://github.com/ev3dev-lang-java/ev3dev-lang-java.git |
| octolytics-dimension-user_id | 17526590 |
| octolytics-dimension-user_login | ev3dev-lang-java |
| octolytics-dimension-repository_id | 45205585 |
| octolytics-dimension-repository_nwo | ev3dev-lang-java/ev3dev-lang-java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 45205585 |
| octolytics-dimension-repository_network_root_nwo | ev3dev-lang-java/ev3dev-lang-java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 927a6c5ab1c32b38830f1b9d3050c0b9e9aa92e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width