-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nose software1 #12
Nose software1 #12
Changes from 11 commits
3185e41
23b9a6d
d75e37a
37b76f5
3f9322f
6ffb118
c1504fd
2807d40
baac4f9
918a4f8
68883fb
1861f6e
5e1f8e0
9f18972
cc9d769
b7cf0ff
0df9e7f
e4688e0
5c8b4d6
0fced30
a400766
30499e9
2ef5251
1884bef
5886f89
f13216a
ef97a3f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# ノーズソフトメモ" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## 使用ライブラリ\n", | ||
"- [MCP3421](https://github.com/uChip/MCP342X)\n", | ||
"- " | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## rp2040を使う上での注意点\n", | ||
"\n", | ||
"- USB認識をしなくなったら,BOOTボタンを押しながらUSB接続し,RP2040のドライブにリセット用のuf2ファイルをドラック&ドロップ\n", | ||
"- Wire.hを使う前に,rp2040はI2Cがいくつもあるので,どのGPIOを使うか宣言する必要がある.\n", | ||
"```\n", | ||
"#define PIN1_SDA 6\n", | ||
"#define PIN1_SCL 7\n", | ||
"Wire.setSDA(PIN1_SDA);\n", | ||
"Wire.setSCL(PIN1_SCL);\n", | ||
"Wire.begin(); \n", | ||
"```\n", | ||
"といったように" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"language_info": { | ||
"name": "python" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#include <Wire.h> | ||
#include <Adafruit_BME280.h> | ||
|
||
|
||
#define SEALEVELPRESSURE_HPA (1013.25) | ||
|
||
Adafruit_BME280 bme; | ||
|
||
unsigned long delayTime; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [cpplint] reported by reviewdog 🐶 |
||
const int clockFrequency = 400000;//I2C bus speed | ||
|
||
void setup() { | ||
Serial.begin(115200); | ||
unsigned status; | ||
Wire.setSDA(6); | ||
Wire.setSCL(7); | ||
Wire.setClock(clockFrequency); | ||
Wire.begin(); | ||
status = bme.begin(0x76); | ||
} | ||
|
||
|
||
void loop() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [cpplint] reported by reviewdog 🐶 |
||
printValues(); | ||
delay(5); | ||
} | ||
|
||
|
||
void printValues() { | ||
Serial.print("Temperature = "); | ||
Serial.print(bme.readTemperature()); | ||
Serial.println(" °C"); | ||
|
||
Serial.print("Pressure = "); | ||
|
||
Serial.print(bme.readPressure() / 100.0F); | ||
Serial.println(" hPa"); | ||
|
||
Serial.print("Approx. Altitude = "); | ||
Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA)); | ||
Serial.println(" m"); | ||
|
||
Serial.print("Humidity = "); | ||
Serial.print(bme.readHumidity()); | ||
Serial.println(" %"); | ||
|
||
Serial.println(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#include <Wire.h> | ||
#include <Adafruit_BME280.h> | ||
#include <MCP342X.h> | ||
|
||
#define SEALEVELPRESSURE_HPA (1013.25) | ||
|
||
Adafruit_BME280 bme; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [cpplint] reported by reviewdog 🐶 |
||
MCP342X myADC; | ||
|
||
unsigned long delayTime; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [cpplint] reported by reviewdog 🐶 |
||
const int clockFrequency = 400000;//I2C bus speed | ||
|
||
double voltage; | ||
|
||
void setup() { | ||
Serial.begin(115200); | ||
unsigned status; | ||
Wire.setSDA(6); | ||
Wire.setSCL(7); | ||
Wire.setClock(clockFrequency); | ||
Wire.begin(); | ||
status = bme.begin(0x76); | ||
myADC.configure( MCP342X_MODE_CONTINUOUS | | ||
MCP342X_CHANNEL_1 | | ||
MCP342X_SIZE_18BIT | | ||
MCP342X_GAIN_1X | ||
); | ||
} | ||
|
||
|
||
void loop() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [cpplint] reported by reviewdog 🐶 |
||
printValues(); | ||
|
||
static int32_t result; | ||
byte bytes[4]; | ||
myADC.startConversion(); | ||
myADC.getResult(&result); | ||
ConvertToVoltage(&result,&voltage); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [cpplint] reported by reviewdog 🐶 |
||
Serial.print("voltage:"); | ||
Serial.println(voltage,10); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [cpplint] reported by reviewdog 🐶 |
||
delay(5); | ||
} | ||
|
||
|
||
void printValues() { | ||
Serial.print("Temperature = "); | ||
Serial.print(bme.readTemperature()); | ||
Serial.println(" °C"); | ||
|
||
Serial.print("Pressure = "); | ||
|
||
Serial.print(bme.readPressure() / 100.0F); | ||
Serial.println(" hPa"); | ||
|
||
Serial.print("Approx. Altitude = "); | ||
Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA)); | ||
Serial.println(" m"); | ||
|
||
Serial.print("Humidity = "); | ||
Serial.print(bme.readHumidity()); | ||
Serial.println(" %"); | ||
|
||
Serial.println(); | ||
} | ||
|
||
void ConvertToVoltage(int32_t* _result,double* voltage){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [cpplint] reported by reviewdog 🐶 |
||
byte bytes[4]; | ||
bytes[3] = (char)(*_result & 0xFF); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [cpplint] reported by reviewdog 🐶 |
||
bytes[2] = (char)((*_result >> 8) & 0xFF); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [cpplint] reported by reviewdog 🐶 |
||
bytes[1] = (char)((*_result >> 16) & 0xFF); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [cpplint] reported by reviewdog 🐶 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [cpplint] reported by reviewdog 🐶 |
||
bytes[0] = (char)((*_result >> 24) & 0xFF); //ライブラリの関数内で8bit右シフトしたときに発生したものなので無視 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [cpplint] reported by reviewdog 🐶 |
||
double pga=1; | ||
double lsb=2*2.048/pow(2,18); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [cpplint] reported by reviewdog 🐶 |
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [cpplint] reported by reviewdog 🐶 |
||
byte msb=(bytes[1]>>6)&0x01; | ||
uint32_t outputcode=bytes[3]|(bytes[2]<<8)|((bytes[1]*0x01)<<16); | ||
if(msb==0x00){//正の値 | ||
*voltage=(double)(outputcode)*lsb/pga; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [cpplint] reported by reviewdog 🐶 |
||
}else{//負の値 | ||
outputcode=((~outputcode)&0x01FFFF)+1;//2の補数 | ||
*voltage=-(double)(outputcode)*lsb/pga; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [cpplint] reported by reviewdog 🐶 |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto | ||
|
||
# Custom for Visual Studio | ||
*.cs diff=csharp | ||
*.sln merge=union | ||
*.csproj merge=union | ||
*.vbproj merge=union | ||
*.fsproj merge=union | ||
*.dbproj merge=union | ||
|
||
# Standard to msysgit | ||
*.doc diff=astextplain | ||
*.DOC diff=astextplain | ||
*.docx diff=astextplain | ||
*.DOCX diff=astextplain | ||
*.dot diff=astextplain | ||
*.DOT diff=astextplain | ||
*.pdf diff=astextplain | ||
*.PDF diff=astextplain | ||
*.rtf diff=astextplain | ||
*.RTF diff=astextplain |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[cpplint] reported by reviewdog 🐶
Line ends in whitespace. Consider deleting these extra spaces. [whitespace/end_of_line] [4]