A pacemaker system is configured to sense electrical and mechanical activity of the heart tissue within a mammalian body and to generate a corresponding signal responsive to the sensed cardiac activity. The system includes a flexible electrical generator that contains EKG (ECG) electrodes for measuring electrical activity and ECHO piezoelectric electrodes for measuring mechanical activity of the heart and Doppler blood flow. The generator is embedded in a flexible shield, and is contoured to conform to the anatomy of the intercostal space to be embedded between the ribs of a patient and in the position overlying the heart. The system provides for pacing as well as defibrillation, responsive to the readings of the heart activities. A microprocessor analyzes a cardiac situation, based on the sensor's readings, produces a diagnosis, and generates control signals, such as “pacing pulse” in a life-threatening situation, or “observe” in a non life-threatening situation.