with lu_argc & lu_argv

This commit is contained in:
MikuQ.com 2016-07-09 22:04:57 +08:00
parent fde95b88a8
commit 51f96b3a01
5 changed files with 83 additions and 6 deletions

View File

@ -11,8 +11,12 @@
*
*/
int main()
int main(int argc,char *argv[])
{
//by Small Lu(mo10), Sky Arrow's first son.
lu_argc=argc;
lu_argv=argv;
mikuPiSetup();
setup();
while(1)

View File

@ -2,6 +2,7 @@
#define _MIKUDUINO_H_
#include <stdio.h>
#include <string.h>
#include "MikuPi.h"
#define D3 bPinTowPin[3]
@ -36,4 +37,7 @@
void setup();
void loop();
int lu_argc;
char **lu_argv;
#endif

View File

@ -1,9 +1,18 @@
#include <string.h>
#include "MikuDuino.h"
#include "Wire.h"
#include "MikuOled.h"
/*
* MikuPi.cpp:
*
* Welcome to MikuQ.com! MikuDuino for BananaPi
*
* by MikuQ(i@mikuq.com)
*
* https://github.com/bpiq/MikuPi
*
*/
uint8 Miku_Oled::buf[OLED_BUFFER_LENGTH+1];

View File

@ -33,14 +33,25 @@ const char *i2cDevices[3] =
const char *piModelNames [7] =
{
"Unknown",
"BPI-M1 ",
"BPI-R1 ",
"BPI-M2 ",
"BPI-M1",
"BPI-R1",
"BPI-M2",
"BPI-M1+",
"BPI-M3 ",
"BPI-M3",
"BPI-M2+",
} ;
const char *piModelFullNames [7] =
{
"Unknown",
"BananaPi-M1",
"BananaPi-R1",
"BananaPi-M2",
"BananaPi-M1+",
"BananaPi-M3",
"BananaPi-M2+",
} ;
int MikuPiDebug = FALSE;
static int *wPinToGpio ;
@ -126,6 +137,53 @@ static void piBoardRevOops (const char *why)
exit (EXIT_FAILURE) ;
}
int piCpuTemp(char* temp)
{
int model, mem;
int iTemp=-300000;
strcpy(temp,"none");
piBoardId (&model, &mem);
FILE *tempFd;
switch(model)
{
case PI_MODEL_UNKNOWN:
case PI_MODEL_M2:
break;
case PI_MODEL_M1:
case PI_MODEL_M1p:
case PI_MODEL_R1:
if ((tempFd = fopen ("/sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/temp1_input", "r")) == NULL)
{
printf("Unable to open /sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/temp1_input\n");
break;
}
while (fgets (temp, 20, tempFd) != NULL)
{
iTemp=atoi(temp);
float f=iTemp/1000.0f;
sprintf(temp,"%.1f",f);
break;
}
fclose(tempFd);
break;
default:
if ((tempFd = fopen ("/sys/class/thermal/thermal_zone0/temp", "r")) == NULL)
{
printf("Unable to open /sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/temp1_input\n");
break;
}
while (fgets (temp, 20, tempFd) != NULL)
{
iTemp=atoi(temp)*1000;
float f=iTemp/1000.0f;
sprintf(temp,"%.0f",f);
break;
}
fclose(tempFd);
}
return iTemp;
}
void piBoardId(int *model, int *mem)
{
FILE *cpuFd ;

View File

@ -33,9 +33,11 @@ extern const int bPinTowPin[41];
#define VERSION "0.30"
extern const char *piModelNames [7] ;
extern const char *piModelFullNames [7];
void delay (unsigned int howLong);
int piCpuTemp(char *temp);
void piBoardId(int *model, int *mem);
void sayHello();