Hi,
I got a strange problem, the error code is'a function-definition is not allowed here before '{' token'
but I check many times , I CANT find any problems that mess up tokens
void updateTime(unsigned long current_time) {
 if(iMinutes >= 0) {
  if(current_time - prevClockTime > UPDATE_TIME_INTERVAL) {
   // Increase time
   iMinutes++;
   if(iMinutes >= 60) {
    iMinutes = 0;
    iHour++;
    if(iHour > 12) {
     iHour = 1;
     (iAmPm == 0) ? iAmPm=1 : iAmPm=0;
     if(iAmPm == 0) {
      iWeek++;
      if(iWeek > 7)
       iWeek = 1;
      iDay++;
      if(iDay > 30) // Yes. day is not exact.
       iDay = 1;
     }
    }
   }
   prevClockTime = current_time;
  }
 }
 else {
  displayMode = DISPLAY_MODE_START_UP;
 }
}
//cloud smartwatch test program v 1.3.1
//Copyright. 2014 Ren Zhiyang All Rights Reserved
//Cloud Development and Sdudy Center.
String comdata = "";Â Â
#include <Adafruit_ssd1306syp.h>
#include "DHT.h"
////////////////////////////////
//////////////////define compass
#include <Wire.h> //I2C Arduino Library
#define address 0x1E //0011110b, I2C 7bit address of HMC5883
/////////////////////////////////
// define GY-61 accerlatmotor pin
const int xpin = A1;Â Â Â Â Â Â Â Â Â // x-axis of the accelerometer
const int ypin = A2;Â Â Â Â Â Â Â Â Â // y-axis
const int zpin = A3;Â Â Â Â Â Â Â Â Â // z-axis (only on 3-axis models)
////////////////////////////////
////////define OLED
#define SDA_PIN 8Â Â //OLED pin
#define SCL_PIN 9Â Â //OLED pin
Adafruit_ssd1306syp display(SDA_PIN,SCL_PIN);
////////////////////////////////////////////
//////////////define DH11 temperature sensor
#define DHTTYPE DHT11
#define DHTPIN 2Â Â Â //temperature sensor pin
DHT dht(DHTPIN, DHTTYPE);
///////////////////////////////////////////
//////////////////////define button input
const int smsButtonPin = 7 ;Â // the number of the pushbutton pin
const int menuButtonPin =6;
const int appButtonPin = 5;
const int okButtonPin = 4;
int smsButtonState = 0;
int menuButtonState = 0;
int appButtonState = 0;
int okButtonState = 0;
/////////////////////////////////////////
/////////////////////////////TIME
#define UPDATE_TIME_INTERVAL 60000
byte iMonth = 1;
byte iDay = 1;
byte iWeek = 1;Â Â // 1: SUN, MON, TUE, WED, THU, FRI,SAT
byte iAmPm = 0;Â Â // 0:AM, 1:PM
byte iHour = 0;
byte iMinutes = 0;
unsigned long current_time = 0;
unsigned long prevClockTime = 0;
///////////////////////////////////////////
/////////////////////////define MODE switch index
#define DISPLAY_MODE_START_UP 0
#define DISPLAY_MODE_CLOCK 1
#define DISPLAY_MODE_SMS 0
#define DISPLAY_MODE_APP 0
/////////////////////////////////
byte displayMode = DISPLAY_MODE_START_UP;
void setup()
{
  /////////////////////////////////////////////////
  //////////////////////////////////RetroWatch said that the serial opened will cause a serious problem
  ////////////////////////test that if something not right
  Serial.begin(9600);
  //////////////////////////////////////////////////
  /////////////////////////////////////////////////
  delay(100);
  display.initialize();
  ////////////////////////////initialized the pushbutton pin as an input
  pinMode(smsButtonPin, INPUT);
  pinMode(menuButtonPin, INPUT);
  pinMode(appButtonPin, INPUT);
  pinMode(okButtonPin, INPUT);
  ///////////////////////////////////////////////////////
 Â
  Wire.begin();
  //Put the HMC5883 IC into the correct operating mode
  Wire.beginTransmission(address); //open communication with HMC5883
  Wire.write(0x02); //select mode register
  Wire.write(0x00); //continuous measurement mode
  Wire.endTransmission();
}
void loop()
{
 Â
  //display temperature and humandity
  buttonInput();
  //////////////////////////////////////////////////////
  current_time = millis();
  updateTime(current_time);
  /////////////////////////////////////////////////////
  onDraw(current_time);/////////////////////need to add more index..
 Â
}
void temandhum()
{
  int h = dht.readHumidity();
  int t = dht.readTemperature();
}
///////////////////////////////////////////////////////////////////////
////////////////////////////////////////////call message display button
void smsCall()
{
Â
  Serial.println("sms");
  delay(25);
  while (Serial.available() > 0)  //Test whether there is data in serial
  {
    comdata += char(Serial.read());
    delay(2);
  }
  if (comdata.length() > 0)
  {
    //Print SMS received
    display.setTextSize(1);
    display.setTextColor(WHITE);
    display.setCursor(0,0);
    display.println(comdata);
    display.update();
    delay(2000);
    comdata = "";
    display.clear();
  }
  else
  {
    display.setTextSize(2);
    display.setTextColor(WHITE);
    display.setCursor(0,30);
    display.println("NO MESSAGE");
    display.update();
    delay(1000);
    display.clear();
  }
Â
}
////////////////////////////////////////////////////////////////////////
/////////////////////////////// GY-271 accelerate output data to android
void acclerOutput()
{
 int x = analogRead(xpin);
 delay(1); //
 int y = analogRead(ypin); //
 delay(1);Â
 int z = analogRead(zpin);
Â
 float zero_G = 512.0; //ADC is 0~1023 the zero g output equal to Vs/2
           //ADXL335 power supply by Vs 3.3V
 float scale = 102.3; //ADXL335330 Sensitivity is 330mv/g
            //330 * 1024/3.3/1000Â
                                       Â
 Serial.print(x);
 Serial.print("\t");
 Serial.print(y);
 Serial.print("\t");
 Serial.print(z);
 Serial.print("\n");
delay(50);
}
/////////////////////////////////////////////////////////////
//////////////////////////////////////////////compass GY-271
void compass()
{
 int a,b,c; //triple axis data
 //Tell the HMC5883 where to begin reading data
 Wire.beginTransmission(address);
 Wire.write(0x03); //select register 3, X MSB register
 Wire.endTransmission();
Â
//Read data from each axis, 2 registers per axis
 Wire.requestFrom(address, 6);
 if(6<=Wire.available()){
  a = Wire.read()<<8; //X msb
  a |= Wire.read(); //X lsb
  c = Wire.read()<<8; //Z msb
  c |= Wire.read(); //Z lsb
  b = Wire.read()<<8; //Y msb
  b |= Wire.read(); //Y lsb
 }
Â
 //Print out values of each axis
 Serial.print("a: ");
 Serial.print(a);
 Serial.print(" b: ");
 Serial.print(b);
 Serial.print(" c: ");
 Serial.println(c);
Â
 delay(250);
}
///////////////////////////////////////////////
/////////////////////////CHECK BUTTON on main screen
void buttonInput()
{
 smsButtonState = digitalRead(smsButtonPin);
 appButtonState = digitalRead(appButtonPin);
 menuButtonState = digitalRead(menuButtonPin);
 if (smsButtonState == HIGH)
 {
  displayMode == DISPLAY_MODE_SMS;
 }
 if (appButtonState == HIGH)
 {
  displayMode == DISPLAY_MODE_APP;
 }
}
////////////////////////////////////////////////////
//////////////////////////////////////check button on sms/app page
void menuButtonInput()
{
 smsButtonState = digitalRead(smsButtonPin);
 appButtonState = digitalRead(appButtonPin);
 menuButtonState = digitalRead(menuButtonPin);
 okButtonState = digitalRead(okButtonPin);
 if (smsButtonState == HIGH)
 {
  rollUp();
 }
 else if (appButtonState == HIGH)
 {
  rollDown();
 }
 else if (menuButtonState == HIGH)
 {
  displayMode = DISPLAY_MODE_CLOCK;
 }
Â
Â
////////////////////////////////////////////////////
////////////////////////////////////update time/////
void updateTime(unsigned long current_time) {
 if(iMinutes >= 0) {
  if(current_time - prevClockTime > UPDATE_TIME_INTERVAL) {
   // Increase time
   iMinutes++;
   if(iMinutes >= 60) {
    iMinutes = 0;
    iHour++;
    if(iHour > 12) {
     iHour = 1;
     (iAmPm == 0) ? iAmPm=1 : iAmPm=0;
     if(iAmPm == 0) {
      iWeek++;
      if(iWeek > 7)
       iWeek = 1;
      iDay++;
      if(iDay > 30) // Yes. day is not exact.
       iDay = 1;
     }
    }
   }
   prevClockTime = current_time;
  }
 }
 else {
  displayMode = DISPLAY_MODE_START_UP;
 }
}
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
void onDraw(unsigned long current_time)
{
 if(!isDisplayTime(currentTime))  // Do not re-draw at every tick
  return;
Â
 if(displayMode == DISPLAY_MODE_START_UP) {
  drawStartUp();
 }
 else if(displayMode == DISPLAY_MODE_CLOCK) {
  drawClock();
 {
 else if(displayMode == DISPLAY_MODE_SMS) {
  drawSms();
 }
 else if(displayMode == DISPLAY_MODE_APP) {
  drawApp();
 }
}
///////////////////////////////////////////////////
////////////////////////////////////////////////
void rollUp() {
Â
}
/////////////////////////////////////////////////////
/////////////////////////////////////////////////
void rollDown() {
Â
}
////////////////////////////////////////////////////
//////////////////////////////////////////////////
void drawClock()
{
 display.clear();
 display.println(iMinute