Пример #1
0
void toLower(string & word)
{
    // convert all upper case letters to lower case
    for (int i = 0; word[i] != '\0'; i++)
	if (isUpperCase(word[i]))
            word[i] = (word[i] - 'A') + 'a'; 
}
Пример #2
0
int isValidKey(char *key) {
    for (int i = 0, l = strlen(key); i < l; i++) {
        if (isLowerCase(key[i]) || isUpperCase(key[i])) {
            return 1;
        }
    }
    return 0;
}
Пример #3
0
    ustring removeAccentFromChar (ustring ch) {
        bool isUp = isUpperCase (ch);
        ch = ch.lowercase ();

        _size_t_ posVowel = getVowelPos (ch);
        if (posVowel != ustring::npos)
            ch = _(Vowels[posVowel]);

        if (isUp)
            ch = ch.uppercase ();
        return ch;
    }
Пример #4
0
    ustring addAccentToChar (ustring ch, Accents accent) {
        bool isUp = isUpperCase (ch);
        ch = ch.lowercase ();

        _size_t_ pos = Vowels.find (ch);
        if (pos != ustring::npos)
            ch = _(VowelsWithAccents[pos * NUMBER_OF_ACCENTS + accent]);

        if (isUp)
            ch = ch.uppercase ();
        return ch;
    }
Пример #5
0
    ustring removeMarkFromChar (ustring ch) {
        bool isUp = isUpperCase (ch);

        _size_t_ pos = getMarkedCharPos (ch);
        _size_t_ accent = getAccentFromChar (ch);

        if (pos != ustring::npos)
            ch = addAccentToChar (_(LettersWithoutMarks[pos]), accent);

        if (isUp)
            ch = ch.uppercase ();
        return ch;
    }
Пример #6
0
    ustring addMarkToChar (ustring ch, Marks mark) {
        bool isUp = isUpperCase (ch);
        _size_t_ accent = getAccentFromChar (ch);

        _size_t_ pos = LettersMayChangeMarks.find
            (removeAccentFromChar (ch).lowercase ());
        if (pos != ustring::npos) {
            ch = addAccentToChar
                (_(LettersWithMarks
                   [mark * LettersWithoutMarks.length () + pos]),
                 accent);
            if (isUp)
                ch = ch.uppercase ();
        }
        return ch;
    }
Пример #7
0
void encryptString(char *sourceStr, char *destStr, char *key) {
    int length = strlen(sourceStr);
    int keyIndex = 0;
    for (int i = 0; i < length; i++) {
        keyIndex = i % strlen(key);
        if (isLowerCase(sourceStr[i])) {
            //printf("for %c in sourceStr, using keyIndex %i, which maps to %c\n", sourceStr[i], keyIndex, key[keyIndex]);
            destStr[i] = encryptChar(sourceStr[i], 97, 122, key[keyIndex]);
        } else if (isUpperCase(sourceStr[i])) {
            destStr[i] = encryptChar(sourceStr[i], 65, 90, key[keyIndex]);
        } else {
            destStr[i] = sourceStr[i];
        }
    }
    destStr[length] = '\0';
}
char toLowerCase(char c){return (isUpperCase(c))?(c+32):c;}//NOTES:toLowerCase(
Пример #9
0
void loop( void )
{
//  Serial.write( '\n' ) ;   // send a char
//  Serial.write( '\r' ) ;   // send a char
//  Serial5.write( '-' ) ;   // send a char

  // adding a constant integer to a string:
  stringThree =  stringOne + 123;
  Serial.println(stringThree);    // prints "stringThree = 123"

  // adding a constant long interger to a string:
  stringThree = stringOne + 123456789;
  Serial.println(stringThree);    // prints " You added 123456789"

  // adding a constant character to a string:
  stringThree =  stringOne + 'A';
  Serial.println(stringThree);    // prints "You added A"

  // adding a constant string to a string:
  stringThree =  stringOne +  "abc";
  Serial.println(stringThree);    // prints "You added abc"

  stringThree = stringOne + stringTwo;
  Serial.println(stringThree);    // prints "You added this string"

  // adding a variable integer to a string:
  int sensorValue = analogRead(A0);
  stringOne = "Sensor value: ";
  stringThree = stringOne  + sensorValue;
  Serial.println(stringThree);    // prints "Sensor Value: 401" or whatever value analogRead(A0) has

  // adding a variable long integer to a string:
  long currentTime = millis();
  stringOne = "millis() value: ";
  stringThree = stringOne + millis();
  Serial.println(stringThree);    // prints "The millis: 345345" or whatever value currentTime has

  // do nothing while true:
  while (true);



#if 0
  // get any incoming bytes:
  if (Serial.available() > 0) {
    int thisChar = Serial.read();

////////    int thisChar = 'a';
    // say what was sent:
    Serial.print("You sent me: \'");
    Serial.write(thisChar);
    Serial.print("\'  ASCII Value: ");
    Serial.println(thisChar);

    // analyze what was sent:
    if (isAlphaNumeric(thisChar)) {
      Serial.println("it's alphanumeric");
    }
    if (isAlpha(thisChar)) {
      Serial.println("it's alphabetic");
    }
    if (isAscii(thisChar)) {
      Serial.println("it's ASCII");
    }
    if (isWhitespace(thisChar)) {
      Serial.println("it's whitespace");
    }
    if (isControl(thisChar)) {
      Serial.println("it's a control character");
    }
    if (isDigit(thisChar)) {
      Serial.println("it's a numeric digit");
    }
    if (isGraph(thisChar)) {
      Serial.println("it's a printable character that's not whitespace");
    }
    if (isLowerCase(thisChar)) {
      Serial.println("it's lower case");
    }
    if (isPrintable(thisChar)) {
      Serial.println("it's printable");
    }
    if (isPunct(thisChar)) {
      Serial.println("it's punctuation");
    }
    if (isSpace(thisChar)) {
      Serial.println("it's a space character");
    }
    if (isUpperCase(thisChar)) {
      Serial.println("it's upper case");
    }
    if (isHexadecimalDigit(thisChar)) {
      Serial.println("it's a valid hexadecimaldigit (i.e. 0 - 9, a - F, or A - F)");
    }

    // add some space and ask for another byte:
    Serial.println();
    Serial.println("Give me another byte:");
    Serial.println();
  }
#endif

#if 0
  sensorValue = analogRead(A0);

  // apply the calibration to the sensor reading
  sensorValue = map(sensorValue, sensorMin, sensorMax, 0, 255);
  Serial.print("sensor = " );
  Serial.print(sensorValue);

  // in case the sensor value is outside the range seen during calibration
  outputValue = constrain(sensorValue, 0, 255);


  // print the results to the serial monitor:
  Serial.print("\t output = ");
  Serial.println(outputValue);

  // fade the LED using the calibrated value:
  analogWrite(9/*ledPin*/, sensorValue);
  
  delay(1);
#endif
#if 0
  // read the analog in value:
  sensorValue = analogRead(A0);
  // map it to the range of the analog out:
  outputValue = map(sensorValue, 0, 1023, 0, 255);
  // change the analog out value:
  analogWrite(9/*analogOutPin*/, outputValue);

  // print the results to the serial monitor:
  Serial.print("sensor = " );
  Serial.print(sensorValue);
  Serial.print("\t output = ");
  Serial.println(outputValue);

  // wait 2 milliseconds before the next loop
  // for the analog-to-digital converter to settle
  // after the last reading:
 delay(2);
//  delay(1000);
#endif

#if 0
  digitalWrite( 0, HIGH ) ;  // set the red LED on
  digitalWrite( 0, LOW ) ;  // set the red LED on

  digitalWrite( 1, HIGH ) ;  // set the red LED on
  digitalWrite( 1, LOW ) ;  // set the red LED on

  digitalWrite( 4, HIGH ) ;  // set the red LED on
  digitalWrite( 4, LOW ) ;  // set the red LED on

  digitalWrite( 5, HIGH ) ;  // set the red LED on
  digitalWrite( 5, LOW ) ;  // set the red LED on

  digitalWrite( 6, HIGH ) ;  // set the red LED on
  digitalWrite( 6, LOW ) ;  // set the red LED on

  digitalWrite( 7, HIGH ) ;  // set the red LED on
  digitalWrite( 7, LOW ) ;  // set the red LED on

  digitalWrite( 8, HIGH ) ;  // set the red LED on
  digitalWrite( 8, LOW ) ;  // set the red LED on

  digitalWrite( 9, HIGH ) ;  // set the red LED on
  digitalWrite( 9, LOW ) ;  // set the red LED on

  digitalWrite( 10, HIGH ) ;  // set the red LED on
  digitalWrite( 10, LOW ) ;  // set the red LED on

  digitalWrite( 11, HIGH ) ;  // set the red LED on
  digitalWrite( 11, LOW ) ;  // set the red LED on

  digitalWrite( 12, HIGH ) ;  // set the red LED on
  digitalWrite( 12, LOW ) ;  // set the red LED on

  digitalWrite( 13, HIGH ) ;  // set the red LED on
  digitalWrite( 13, LOW ) ;  // set the red LED on
#endif

#if 0
//    int a = 123;
//    Serial.print(a, DEC);

//  for ( uint32_t i = A0 ; i <= A0+NUM_ANALOG_INPUTS ; i++ )
  for ( uint32_t i = 0 ; i <= NUM_ANALOG_INPUTS ; i++ )
  {

    int a = analogRead(i);
//    int a = 123;
    Serial.print(a, DEC);
    Serial.print(" ");
//   Serial.write( ' ' ) ;   // send a char
//   Serial.write( 0x30 + i ) ;   // send a char

//   Serial.write( 0x30 + ((a/1000)%10) ) ;   // send a char
//   Serial.write( 0x30 + ((a/100)%10) ) ;   // send a char
//   Serial.write( 0x30 + ((a/10)%10) ) ;   // send a char
//   Serial.write( 0x30 + (a%10) ) ;   // send a char
//   Serial.write( ' ' ) ;   // send a char
  }
  Serial.println();
#endif

#if 0
  volatile int pin_value=0 ;
  static volatile uint8_t duty_cycle=0 ;
  static volatile uint16_t dac_value=0 ;

  // Test digitalWrite
  led_step1() ;
  delay( 500 ) ;              // wait for a second
  led_step2() ;
  delay( 500 ) ;              // wait for a second

  // Test Serial output
  Serial5.write( '-' ) ;   // send a char
  Serial5.write( "test1\n" ) ;   // send a string
  Serial5.write( "test2" ) ;   // send another string

  // Test digitalRead: connect pin 2 to either GND or 3.3V. !!!! NOT on 5V pin !!!!
  pin_value=digitalRead( 2 ) ;
  Serial5.write( "pin 2 value is " ) ;
  Serial5.write( (pin_value == LOW)?"LOW\n":"HIGH\n" ) ;

  duty_cycle+=8 ;//=(uint8_t)(millis() & 0xff) ;
  analogWrite( 13, duty_cycle ) ;
  analogWrite( 12, duty_cycle ) ;
  analogWrite( 11, duty_cycle ) ;
  analogWrite( 10 ,duty_cycle ) ;
  analogWrite(  9, duty_cycle ) ;
  analogWrite(  8, duty_cycle ) ;

  dac_value += 64;
  analogWrite(A0, dac_value);



  Serial5.print("\r\nAnalog pins: ");

  for ( uint32_t i = A0 ; i <= A0+NUM_ANALOG_INPUTS ; i++ )
  {

    int a = analogRead(i);
    Serial5.print(a, DEC);
    Serial5.print(" ");

  }
  Serial5.println();

  Serial5.println("External interrupt pins:");
  if ( ul_Interrupt_Pin3 == 1 )
  {
    Serial5.println( "Pin 3 triggered (LOW)" ) ;
    ul_Interrupt_Pin3 = 0 ;
  }

  if ( ul_Interrupt_Pin4 == 1 )
  {
    Serial5.println( "Pin 4 triggered (HIGH)" ) ;
    ul_Interrupt_Pin4 = 0 ;
  }

  if ( ul_Interrupt_Pin5 == 1 )
  {
    Serial5.println( "Pin 5 triggered (FALLING)" ) ;
    ul_Interrupt_Pin5 = 0 ;
  }

  if ( ul_Interrupt_Pin6 == 1 )
  {
    Serial5.println( "Pin 6 triggered (RISING)" ) ;
    ul_Interrupt_Pin6 = 0 ;
  }

  if ( ul_Interrupt_Pin7 == 1 )
  {
    Serial5.println( "Pin 7 triggered (CHANGE)" ) ;
    ul_Interrupt_Pin7 = 0 ;
  }
#endif
}
Пример #10
0
 bool isLowerCase (ustring ch) {
     return !isUpperCase (ch);
 }
Пример #11
0
 bool isUpperCase (guint ch) {
     return isUpperCase (_(ch));
 }
Пример #12
0
 bool isUpperCase (const gchar *ch) {
     return isUpperCase (_(ch));
 }
Пример #13
0
 bool isUpperCase (string ch) {
     return isUpperCase (_(ch));
 }